时间:2021-07-01 10:21:17 帮助过:3人阅读
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'
其中,Ado可以使用charPage这个属性来设置uft-8,类似new COM的方式。但发现当将AdoNewConnection($dbdriver)的$dbdriver设为'ado'或'ado_mssql'时,其传进去的database被替换为provider。那database的名字如何设置呢?一直没找到办法。
$dbdriver='ado://sa:cvttdev@172.16.22.40/sqloledb?charpage=65001';
其格式是'driver://user:passwd@host/database?options[=value]
但没解决设置数据库名字的地方。
痛苦了很久,只能找到如下的办法解决:
代码如下:
$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 "";";
print_r($rs->GetRows());
print "
?>
http://www.bkjia.com/PHPjc/320222.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/320222.htmlTechArticle周海汉/文 ADO可以用 new COM("ADODB.Connection", NULL, CP_UTF8)//65001 这样的语句来实现正确转换。但ADO对php的支持缺乏文档。而有个开源的adodb,文档...