From: Domas Mituzas Date: Fri, 11 Jun 2004 15:54:29 +0000 (+0000) Subject: de-mysql: remove REPLACE INTO and DELETE .. LIMIT for nonmysql X-Git-Tag: 1.5.0alpha1~2911 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22articles%22%2C%22id_article=%24id_article%22%29%20.%20%22?a=commitdiff_plain;h=7b8efba71bb04820d0b09db4d0ee459e192053be;p=lhc%2Fweb%2Fwiklou.git de-mysql: remove REPLACE INTO and DELETE .. LIMIT for nonmysql --- diff --git a/includes/WatchedItem.php b/includes/WatchedItem.php index 74371be4bf..23ad2804e1 100644 --- a/includes/WatchedItem.php +++ b/includes/WatchedItem.php @@ -36,10 +36,22 @@ class WatchedItem { function addWatch() { + global $wgIsMySQL; # REPLACE instead of INSERT because occasionally someone # accidentally reloads a watch-add operation. - $sql = "REPLACE INTO watchlist (wl_user, wl_namespace,wl_title) VALUES ($this->id,$this->ns,'$this->eti')"; - $res = wfQuery( $sql, DB_WRITE ); + if ($wgIsMySQL) { + $sql = "REPLACE INTO watchlist (wl_user, wl_namespace,wl_title) ". + "VALUES ($this->id,$this->ns,'$this->eti')"; + $res = wfQuery( $sql, DB_WRITE ); + } else { + $sql = "DELETE FROM watchlist WHERE wl_user=$this->id AND + wl_namespace=$this->ns AND wl_title='$this->eti'"; + wfQuery( $sql, DB_WRITE); + $sql = "INSERT INTO watchlist (wl_user, wl_namespace,wl_title) ". + "VALUES ($this->id,$this->ns,'$this->eti')"; + $res = wfQuery( $sql, DB_WRITE ); + } + if( $res === false ) return false; global $wgMemc; @@ -49,7 +61,7 @@ class WatchedItem { function removeWatch() { - $sql = "DELETE FROM watchlist WHERE wl_user=$this->id AND wl_namespace=$this->ns AND wl_title='$this->eti' LIMIT 1"; + $sql = "DELETE FROM watchlist WHERE wl_user=$this->id AND wl_namespace=$this->ns AND wl_title='$this->eti'"; $res = wfQuery( $sql, DB_WRITE ); if( $res === false ) return false;