MySQL 伺服器版本: 5.0.22-log
問題點:寫入 UTF-8編碼中文字進MySQL DB,變成亂碼


修改: adodb/drivers/adodb-mysql.inc.php
兩個連線function _connect _pconnect
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
if (ADODB_PHPVER >= 0x4300)
$this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword,
$this->forceNewConnect,$this->clientFlags);
else if (ADODB_PHPVER >= 0x4200)
$this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword,
$this->forceNewConnect);
else
$this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword);

if ($this->_connectionID === false) return false;

+ @mysql_query("SET NAMES 'utf8'", $this->_connectionID);

if ($argDatabasename) return $this->SelectDB($argDatabasename);
return true;
}

function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
if (ADODB_PHPVER >= 0x4300)
$this->_connectionID =
mysql_pconnect($argHostname,$argUsername,$argPassword,$this->clientFlags);
else
$this->_connectionID = mysql_pconnect($argHostname,$argUsername,$argPassword);
if ($this->_connectionID === false) return false;
+ @mysql_query("SET NAMES 'utf8'", $this->_connectionID);
if ($this->autoRollback) $this->RollbackTrans();
if ($argDatabasename) return $this->SelectDB($argDatabasename);
return true;
}

 

原文取自 http://fhkkta.blogspot.com/2008/06/adodb-mysql-utf-8-problem-fix.html


arrow
arrow
    全站熱搜
    創作者介紹
    創作者 Frank 的頭像
    Frank

    經驗交流分享與備忘

    Frank 發表在 痞客邦 留言(0) 人氣()