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 opencv 无法读取视频
  • ¥15 用matlab 实现通信仿真
  • ¥15 按键修改电子时钟,C51单片机
  • ¥60 Java中实现如何实现张量类,并用于图像处理(不运用其他科学计算库和图像处理库))
  • ¥20 5037端口被adb自己占了
  • ¥15 python:excel数据写入多个对应word文档
  • ¥60 全一数分解素因子和素数循环节位数
  • ¥15 ffmpeg如何安装到虚拟环境
  • ¥188 寻找能做王者评分提取的
  • ¥15 matlab用simulink求解一个二阶微分方程,要求截图