[英]PDO drivers are installed, but connection test says otherwise
I'm trying to connect to my database using PDO drivers and as far as I know they are installed correctly. 我正在尝试使用PDO驱动程序连接到我的数据库,据我所知它们已正确安装。 I have added the extensions to my php.ini file and the drivers are in the ext folder, I downloaded Microsoft drivers 3.0.
我已将扩展添加到我的php.ini文件中,驱动程序位于ext文件夹中,我下载了Microsoft驱动程序3.0。 PHPinfo() says pdo_sqlsrv drivers are enabled.
PHPinfo()表示启用了pdo_sqlsrv驱动程序。 I'm using a Windows server with iis.
我正在使用带有iis的Windows服务器。 I have PHP 5.4 installed and using the non-thread safe drivers.
我安装了PHP 5.4并使用非线程安全驱动程序。 What else could I be missing?
我还能错过什么?
<?php
try{
$dbh = new pdo( 'sqlsrv=websvr\sqlwebdata:1433;dbname=xxxx',
'xxxx',
'xxxx',
array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
die(json_encode(array('outcome' => true)));
}
catch(PDOException $ex){
print "Error!: " . $ex->getMessage() . "<br/>";
die();
} }
?> ?>
http://docs.php.net/manual/de/pdo.construct.php says: http://docs.php.net/manual/de/pdo.construct.php说:
PDO::__construct() ( string $dsn, ...PDO :: __ construct()(string $ dsn,...
[...][...]
In general, a DSN consists ofthe PDO driver name, followed by a colon, followed by the PDO driver-specific connection syntax
通常,DSN由PDO驱动程序名称,后跟冒号,后跟PDO驱动程序特定的连接语法组成
try it with (edit: fixed Database= keyword) 尝试一下(编辑:fixed Database = keyword)
new pdo( 'sqlsrv:Server=websvr\sqlwebdata,1433;Database=xxxx',
see also: http://php.net/ref.pdo-sqlsrv.connection 另见: http : //php.net/ref.pdo-sqlsrv.connection
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.