- 操作系统:Windows 8.1
- 架构:x64
- PHP:PHP 7.1.6
- mssql:Mssql Server 2014 express
- 驱动程序:SQLSRV 4.0
- 集成开发环境:PhpStorm
我正在尝试让 mssql 驱动程序工作。
我从微软下载了 pdo 驱动程序,将文件 php_pdo_sqlsrv_7_nts_x64.dll
放入 C:\Program Files\PHP\ext
并编辑了 php.ini
添加 extension=php_pdo_sqlsrv_7_nts_x64.dll
到它。
这是结果:
$ php -v
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\Program Files\PHP\ext\php_pdo_sqlsrv_7_nts_x64.dll' - The specified procedure could not be found.
in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library 'C:\Program Files\PHP\ext\php_sqlsrv_7_nts_x64.dll.dll' - The specified procedure could not be found.
in Unknown on line 0
PHP 7.1.6 (cli) (built: Jun 8 2017 01:53:41) ( ZTS MSVC14 (Visual C++ 2015) x64 )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
可能与此重复: PHP Warning: PHP Startup: Unable to load dynamic library php_pdo_mssql.dll
但那个人从来没有回答过,而且已经四岁了。
最佳答案
在我的例子中,这个错误(但使用不同的 DLL 版本)是由于向我的 PHP 扩展添加了错误的 PHP SQL SLQSRV DLL 引起的:
我正在使用来自 XAMPP 的 PHP 7.2.21。
我添加了这些 DLL(包含在 SQLSRV561.exe 中):
- php_pdo_sqlsrv_72_ts_x64.dll
- php_pdo_sqlsrv_72_ts_x86.dll
- php_pdo_sqlsrv_72_nts_x64.dll
- php_pdo_sqlsrv_72_nts_x86.dll
我启用了 php_pdo_sqlsrv_72_nts_x64.dll
作为 PHP 扩展,但是 nts dll 版本不适合我的 PHP 版本。当我启用 ts dll 版本时,错误消失了。 (我正在使用 IIS。)
Thread Safe (TS) and Non-Thread Safe (NTS) are the two different PHP builds available.
关于PHP 警告 PHP 启动无法加载动态库 php_pdo_sqlsrv_7_ts_x64.dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44784102/