Zhou Haihan/Text
ADO can use statements like new COM("ADODB.Connection", NULL, CP_UTF8)//65001 to achieve correct conversion. But ADO's support for php lacks documentation. There is open source adodb, which has rich documentation.
The method of setting UTF-8 is different for different database drivers, as follows:
Copy the code The 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'
Among them, Ado can use the charPage attribute to set uft-8, similar to new COM. But I found that when the $dbdriver of AdoNewConnection($dbdriver) is set to 'ado' or 'ado_mssql', the database passed in is replaced by provider. How to set the name of the database? Haven't found a way yet.
$dbdriver='ado://sa:cvttdev@172.16.22.40/sqloledb?charpage=65001';
The format is 'driver://user:passwd@host/database?options[=value]
But it does not solve the problem of setting the database name.
After suffering for a long time, I can only find the following solution:
Copy the code The code is as follows:
< ;body>
$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};DATABASE=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 "
"; <br>print_r($rs->GetRows()); <br>print "
";
?>
http://www.bkjia.com/PHPjc/320222.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/320222.htmlTechArticleZhou Haihan/Wen ADO can use new COM("ADODB.Connection", NULL, CP_UTF8)//65001 like this statement to achieve correct conversion. But ADO's support for php lacks documentation. There is an open source adodb, documentation...