MySQL is the only database which quotes identifiers primarily using backticks. Move...
authorDaniel Friesen <dantman@users.mediawiki.org>
Sat, 4 Dec 2010 15:35:36 +0000 (15:35 +0000)
committerDaniel Friesen <dantman@users.mediawiki.org>
Sat, 4 Dec 2010 15:35:36 +0000 (15:35 +0000)
includes/db/Database.php
includes/db/DatabaseIbm_db2.php
includes/db/DatabaseMssql.php
includes/db/DatabaseMysql.php
includes/db/DatabaseOracle.php
includes/db/DatabasePostgres.php
includes/db/DatabaseSqlite.php

index 7248bb9..6d4ba86 100644 (file)
@@ -1695,12 +1695,13 @@ abstract class DatabaseBase implements DatabaseType {
        }
 
        /**
-        * Quotes a string using `backticks` for things like database, table, and field
-        * names, other databases which use something other than backticks can replace
-        * this with something else
+        * Quotes an identifier using `backticks` or "double quotes" depending on the database type.
+        * MySQL uses `backticks` while basically everything else uses double quotes.
+        * Since MySQL is the odd one out here the double quotes are our generic
+        * and we implement backticks in DatabaseMysql.
         */      
        public function addIdentifierQuotes( $s ) {
-               return "`" . $this->strencode( $s ) . "`";
+               return '"' . str_replace( '"', '""', $s ) . '"';
        }
 
        /**
index f49ff8e..a3a6829 100644 (file)
@@ -647,10 +647,6 @@ EOF;
                }
        }
 
-       public function addIdentifierQuotes( $s ) {
-               return '"' . str_replace( '"', '""', $s ) . '"';
-       }
-
        /**
         * Verifies that a DB2 column/field type is numeric
         *
index b51f782..4f09069 100644 (file)
@@ -997,10 +997,6 @@ class DatabaseMssql extends DatabaseBase {
                }
        }
 
-       function addIdentifierQuotes( $s ) {
-               return "'" . str_replace( "'", "''", $s ) . "'";
-       }
-
        function selectDB( $db ) {
                return ( $this->query( "SET DATABASE $db" ) !== false );
        }
index bc41cb1..2b2c969 100644 (file)
@@ -322,6 +322,13 @@ class DatabaseMysql extends DatabaseBase {
                return $sQuoted;
        }
 
+       /**
+        * MySQL uses `backticks` for identifier quoting instead of the sql standard "double quotes".
+        */
+       public function addIdentifierQuotes( $s ) {
+               return "`" . $this->strencode( $s ) . "`";
+       }
+
        function ping() {
                $ping = mysql_ping( $this->mConn );
                if ( $ping ) {
index b5d67dd..c5f6a3d 100644 (file)
@@ -1125,10 +1125,6 @@ class DatabaseOracle extends DatabaseBase {
                return "'" . $this->strencode( $s ) . "'";
        }
 
-       function addIdentifierQuotes( $s ) {
-               return '"' . str_replace( '"', '""', $s ) . '"';
-       }
-
        function selectRow( $table, $vars, $conds, $fname = 'DatabaseOracle::selectRow', $options = array(), $join_conds = array() ) {
                global $wgContLang;
 
index 55385f0..96f7eae 100644 (file)
@@ -1300,10 +1300,6 @@ SQL;
                return "'" . pg_escape_string( $this->mConn, $s ) . "'";
        }
 
-       function addIdentifierQuotes( $s ) {
-               return '"' . str_replace( '"', '""', $s ) . '"';
-       }
-
        /**
         * Postgres specific version of replaceVars.
         * Calls the parent version in Database.php
index 6fb59f7..52637a2 100644 (file)
@@ -530,10 +530,6 @@ class DatabaseSqlite extends DatabaseBase {
                }
        }
 
-       function addIdentifierQuotes( $s ) {
-               return '"' . str_replace( '"', '""', $s ) . '"';
-       }
-
        function buildLike() {
                $params = func_get_args();
                if ( count( $params ) > 0 && is_array( $params[0] ) ) {