Use the native set_charset() method if available instead of SET NAMES
[lhc/web/wiklou.git] / includes / db / DatabaseMysqlBase.php
index cdfa769..5be460f 100644 (file)
@@ -114,9 +114,9 @@ abstract class DatabaseMysqlBase extends DatabaseBase {
                // Tell the server we're communicating with it in UTF-8.
                // This may engage various charset conversions.
                if ( $wgDBmysql5 ) {
-                       $this->query( 'SET NAMES utf8', __METHOD__ );
+                       $this->mysqlSetCharset( 'utf8' );
                } else {
-                       $this->query( 'SET NAMES binary', __METHOD__ );
+                       $this->mysqlSetCharset( 'binary' );
                }
                // Set SQL mode, default is turning them all off, can be overridden or skipped with null
                if ( is_string( $wgSQLMode ) ) {
@@ -138,6 +138,14 @@ abstract class DatabaseMysqlBase extends DatabaseBase {
         */
        abstract protected function mysqlConnect( $realServer );
 
+       /**
+        * Set the character set of the MySQL link
+        *
+        * @param string $charset
+        * @return bool
+        */
+       abstract protected function mysqlSetCharset( $charset );
+
        /**
         * @param $res ResultWrapper
         * @throws DBUnexpectedError