return $conn;
}
+ /**
+ * @return bool
+ */
+ protected function mysqlSetCharset( $charset ) {
+ if ( function_exists( 'mysql_set_charset' ) ) {
+ return mysql_set_charset( $charset, $this->mConn );
+ } else {
+ return $this->query( 'SET NAMES ' . $charset, __METHOD__ );
+ }
+ }
+
/**
* @return bool
*/
// 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 ) ) {
*/
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
return false;
}
+ /**
+ * @return bool
+ */
+ protected function mysqlSetCharset( $charset ) {
+ if ( method_exists( $this->mConn, 'set_charset' ) ) {
+ return $this->mConn->set_charset( $charset );
+ } else {
+ return $this->query( 'SET NAMES ' . $charset, __METHOD__ );
+ }
+ }
+
/**
* @return bool
*/
// From DatabaseMysql
protected function mysqlConnect( $realServer ) {}
+ protected function mysqlSetCharset( $charset ) {}
protected function mysqlFreeResult( $res ) {}
protected function mysqlFetchObject( $res ) {}
protected function mysqlFetchArray( $res ) {}