我跟着http://ccca.net/~cwyeh/adodb_mysql_4.1.patch做了下
--- adodb-mysql.inc.php.bak Wed Jun 15 19:58:22 2005
+++ adodb-mysql.inc.php Thu Jun 16 00:55:58 2005
@@ -351,6 +351,7 @@
$this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword);
if ($this->_connectionID === false) return false;
if ($argDatabasename) return $this->SelectDB($argDatabasename);
return true;
}
@@ -364,6 +365,7 @@
$this->_connectionID = mysql_pconnect($argHostname,$argUsername,$argPassword);
if ($this->_connectionID === false) return false;
if ($this->autoRollback) $this->RollbackTrans();
if ($argDatabasename) return $this->SelectDB($argDatabasename);
return true;
}
@@ -374,6 +376,43 @@
return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename);
}
+ function _isSupportUtf8()
+ {
+ // check mysql version first. Version lower than 4.1 doesn't support utf8
+ $serverVersion = mysql_get_server_info($this->_connectionID);
+ $version = explode('.', $serverVersion);
+ if ($version[0] < 4) return false;
+ if ( ($version[0] == 4) && ($version[1] == 0) ) return false;
+
+ // check if utf8 support was compiled in
+ $result = mysql_query("SHOW CHARACTER SET like 'utf8'", $this->_connectionID);
+ if (mysql_num_rows($result) > 0) {
+ return true;
+ }
+ return false;
+ }
+
+ function _getDbDefaultEncoding($argDatabasename)
+ {
+ if (!$argDatabasename) {
+ return false;
+ }
+
+ // We use a SHOW CREATE DATABASE command to show the original
+ // SQL character set when DB was created.
+ $result = mysql_query("SHOW CREATE DATABASE $argDatabasename", $this->_connectionID);
+ if (mysql_num_rows($result) < 0 ) {
+ // The specified db name is wrong!
+ return false;
+ }
+ $dbInfo = mysql_fetch_row($result);
+ $pattern = '/40100 DEFAULT CHARACTER SET (\w+) /';
+ if ( (preg_match($pattern, $dbInfo[1], $match) > 0) ) {
+ return $match[1];
+ }
+ return false;
+ }
+
function &MetaColumns($table)
{
global $ADODB_FETCH_MODE;
@@ -445,7 +484,14 @@
function SelectDB($dbName)
{
$this->databaseName = $dbName;
if ($this->_connectionID) {
+ if ($this->_isSupportUtf8() && $dbName) {
+ $dbEncoding = $this->_getDbDefaultEncoding($argDatabasename);
+ if ($dbEncoding) {
+ mysql_query("SET NAMES $dbEncoding", $this->_connectionID);
+ }
+ }
return @mysql_select_db($dbName,$this->_connectionID);
}
else return false;
但是没有解决错别字问题,我的修改是直接把+号的东西加进去,因为不太理解作者的意图.
这是mark说的网址http://bugs.lifetype.net/view.php?id=590
用废弃的金山研究了好久依旧没解决,希望快点解决~支持plog