以下是我的尝试......
代码:
try {
//as seen in comments on php.net
//$mssql = new PDO('sqlsrv:host=ip;port=port;dbname=db','user','pass');
//$mssql = new PDO('mssql:host=ip,port;dbname=db', 'user', 'pass');
//$mssql = new PDO('mssql:server=ip\SQLEXPRESS; Database=db', 'user', 'pass');
//as seen in the SQLSRV_Help.chm
//$mssql = new PDO('sqlsrv:server=ip; Database=db', 'user', 'pass');
//as seen on php.net
$db = new PDO("sqlsrv:Server=ip,port;Database=db", "user", "pass");
} catch(PDOException $e) {
echo $e->getMessage();
}
消息:could not find driver
问题1:什么是正确的连接语法?
问题2:我是否错过了启用驱动程序的功能(请参阅其他信息)?
其他信息:
系统:Windows (Wampserver) - PHP 5.3 VC9 ThreadSafe
在php.ini中(重启服务器后):
extension=php_pdo_sqlsrv_53_ts.dll
extension=php_pdo_sqlsrv_53_ts_vc9.dll
extension=php_sqlsrv_53_ts.dll
extension=php_sqlsrv_53_ts_vc9.dll
dll也在ext /文件夹中
答案 0 :(得分:0)
我使用了ODBC-SQL Native Client驱动程序,这可行
$db = new PDO("odbc:Driver={SQL Native Client};Server=ip,port;Database=db;Uid=user;Pwd=pass;");