Zhou Haihan/Wen
ADO can be used with new COM ("ADODB. Connection ", NULL, Cp_utf8)//65001 Such statements to achieve the correct conversion. However, ADO lacks documentation for PHP support. And there is an open source ADODB, the document is richer.
The method of setting UTF-8 for different database drivers is not the same, as follows:
Copy CodeThe code is as follows:
For all drivers
' Persist ', ' persistent ', ' Debug ', ' Fetchmode ', ' new '
Interbase/firebird
' Dialect ', ' charset ', ' buffers ', ' role '
M ' Soft ADO
' Charpage '
Mysql
' Clientflags '
Mysqli
' Port ', ' socket ', ' clientflags '
Oci8
' Nls_date_format ', ' CharSet '
For all drivers
' Persist ', ' persistent ', ' Debug ', ' Fetchmode ', ' new '
Interbase/firebird
' Dialect ', ' charset ', ' buffers ', ' role '
M ' Soft ADO
' Charpage '
Mysql
' Clientflags '
Mysqli
' Port ', ' socket ', ' clientflags '
Oci8
' Nls_date_format ', ' CharSet '
Where ADO can use the Charpage property to set Uft-8, like the new COM way. However, it is found that when the Adonewconnection ($dbdriver) $dbdriver is set to ' ADO ' or ' Ado_mssql ', the database it passes in is replaced by provider. How does the database name be set? I've never found a way.
$dbdriver = ' ado://sa:cvttdev@172.16.22.40/sqloledb?charpage=65001 ';
The format is ' Driver://user:passwd@host/database?options[=value '
But the place where the database name is set is not resolved.
Pain for a long time, can only find the following ways to solve:
Copy CodeThe code is as follows:
$dbdriver = ' Ado_mssql ';
$server = ' 192.168.22.40 ';
$user = ' sa ';
$password = ' passwd ';
$DATABASE = ' sugarcrm_db ';
$database = ' SQLOLEDB ';
$dbdriver = ' ado://sa:cvttdev@172.16.22.40/sqloledb?charpage=65001 ';
$myDSN = "Provider=msdasql;driver={sql Server}; server={172.16.22.40};D atabase=sugarcrm_db; Uid=sa; Pwd=cvttdev; ";
Include (' adodb5/adodb.inc.php ');
$db = Adonewconnection ($dbdriver); # eg ' MySQL ' or ' postgres '
$db->debug = true;
$db->charpage = 65001;
$db->connect ($server, $user, $password, $database);
$db->connect ($myDSN);
Error:mssql server not support codes below
$db->execute ("Set names ' UTF8 '");
echo "before query";
$rs = $db->execute (' select * from accounts ');
Print "
Print "
";
?>
http://www.bkjia.com/PHPjc/320222.html www.bkjia.com true http://www.bkjia.com/PHPjc/320222.html techarticle Zhou Haihan/text ADO can be used with new COM ("ADODB". Connection ", NULL, Cp_utf8)//65001 Such statements to achieve the correct conversion. However, ADO lacks documentation for PHP support. And there's an open source ADODB, Doc ...