duankuaizhe8257 2014-08-21 11:03
浏览 804

尽管已安装和启用驱动程序,但PHP(PDO)的SQL Server访问无法正常工作

I am trying to access an SQL Server.

UPDATE: In response to Clive's comments below I have also tried reinstalling the native ODBC driver but no change.

I've checked over all the questions I can find on this and everything seems to be in order. My server details:

PHP 5.4 (Managed via Plesk)
SQL Server 2008 R2 SP2
Windows Server 2008 R2

The latest mssql drivers for PDO are in the EXT directory and referenced in php.ini:

extension=php_sqlsrv_54_nts.dll
extension=php_pdo_sqlsrv_54_nts.dll

PHPINFO() gives the following:

PDO Drivers: mysql, sqlite, sqlsrv
pdo_sqlsrv support: enabled
sqlsrv support:  enabled

My connection string looks like this:

$DSN = "sqlsrv:Server=myDbServer,1433;database=my-dbname";
$PdoOptions = array(
    PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
    PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
);
$sparklyGenericPdoObj = new PDO($DSN,'myUsername','myPasswurde', $PdoOptions);

But that just gives me the following error which links - in a roundabout way - to the drivers I already have installed (I've checked the version numbers):

PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[IMSSP]: This extension requires the Microsoft SQL Server 2012 Native Client ODBC Driver to communicate with SQL Server. Access the following URL to download the Microsoft SQL Server 2012 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712'

On this thread (reporting exactly the same error as me) is a solution which says that you can confirm the driver is installed by looking for the items I've mentioned above in PHPINFO: Not getting connected to Sql Server 2012!

Any help would be much appreciated!

  • 写回答

3条回答 默认 最新

  • dorkahemp972157683 2014-08-21 14:13
    关注

    In the end I solved this by installing the "Microsoft® SQL Server® 2012 SP1 Command Line Utilities" from here (SqlCmdLnUtils.msi):

    http://www.microsoft.com/en-in/download/details.aspx?id=35580

    No idea why this worked but there it is.

    评论

报告相同问题?

悬赏问题

  • ¥15 flink cdc无法实时同步mysql数据
  • ¥100 有人会搭建GPT-J-6B框架吗?有偿
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名