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 虚拟机打包apk出现错误
  • ¥30 最小化遗憾贪心算法上界
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝