我最近升级了我的 PHP 和 sqlsrv 驱动程序。这是我为 SQLSRV 部分所做的:
首先,我的 phpinfo() 产生:
PHP Version 5.5.1
System: Windows NT HOSTNAME 6.1 build 7601 (Windows 7 Business Edition Service Pack 1) i586
Build Date: Jul 18 2013 10:37:55
Compiler: MSVC11 (Visual C++ 2012)
Architecture: x86
Configure Command
cscript /nologo configure.js "--enable-snapshot-build" "--enable-debug-pack" "--disable-zts" "--disable-isapi" "--disable-nsapi" "--without-mssql" "--without-pdo-mssql" "--without-pi3web" "--with-pdo-oci=C:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8=C:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8-11g=C:\php-sdk\oracle\instantclient11\sdk,shared" "--with-enchant=shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--with-mcrypt=static" "--disable-static-analyze" "--with-pgo"
然后我将 SQLSRV 驱动安装到 C:\Program Files (x86)\PHP\ext 文件中,并在 php.ini 中添加:
[PHP_SQLSRV]
extension=php_sqlsrv_53_nts_vc9.dll
[PHP_PDOSQLSRV]
extension=php_pdo_sqlsrv_53_nts_vc9.dll
它有效。虽然我不直接调用函数(我使用 Yii 框架),但我也更改了 DSN:
sqlsrv:Server=hostname_or_ip;Database=your_database_name;
希望能帮助到你。
编辑
我从http://social.msdn.microsoft.com/Forums/sqlserver/en-US/e1d37219-88a3-46b2-a421-73bfa33fe433/unofficial-php-55-drivers-x86下载了 PHP 5.5 的实验性/非官方 sqlsrv 驱动程序并将我的配置更新为:
[PHP_SQLSRV]
extension=php_sqlsrv_55_nts.dll
[PHP_PDOSQLSRV]
extension=php_pdo_sqlsrv_55_nts.dll
发现自:https ://stackoverflow.com/a/17390741/2236500