Zhou Haihan/Wen
ADO can be used with new COM ("ADODB". Connection ", NULL, Cp_utf8)//65001 such a statement to implement the correct conversion. But ADO's support for PHP lacks documentation. And there is an open source ADODB, the document is richer.
In which the different database drivers, set the UTF-8 method is not the same, as follows:
Copy Code code 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 '
Among them, ADO can use Charpage this property to set uft-8, like new COM way. However, it was found that when the $dbdriver of Adonewconnection ($dbdriver) was set to ' ADO ' or ' Ado_mssql ', the database passed in was replaced by provider. How do you set the name of the database? Never found a way.
$dbdriver = ' ado://sa:cvttdev@172.16.22.40/sqloledb?charpage=65001 ';
Its format is ' driver://user:passwd@host/database?options[=value]
But did not resolve the place where the database name was set.
Suffering for a long time, can only find the following solution:
Copy Code code as follows:
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<body>
<?php
$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 "<pre>";
Print_r ($rs->getrows ());
print "</pre>";
?>
</body>