SQL Server 2016 的 Microsoft 驱动程序 - 安装

Microsoft Driver for SQL Server 2016 - Installation

我的问题是基于这个 post's answer from @Crontab. I downloaded SQLSRV40 from Microsoft website。当我尝试安装时,它要求

安装时,我必须输入解压文件的路径,正如网站安装说明第 3 "When prompted, enter the path to the PHP extensions directory" 中提到的那样。

我有xampp,还有一个php文件目录。对于我的提取路径,我应该只给出 'C:/xampp/php' 吗?

我有点困惑,因为在答案的评论部分下,@Crontab 提到了 "My guess would be wherever you find all the other php_*.dll files"。这意味着所有 php_*.dll 文件都应该在 php 文件夹下,对吗?

此外,比如说,如果我将它们解压到那个文件夹或不同的文件夹中,当我将 php_pdo_sqlsrv_7_nts_x64 添加到我的 php.ini 文件夹并通过 apache 连接时,我找不到我的 pdo_sqlsrv dll。

这是我第一次安装 SQL 服务器驱动器。如有任何建议,我们将不胜感激。

似乎主要问题是 sqlsrv Microsoft 网站上可供下载的驱动程序目前仅支持 PHP 7.0.+,即不支持 PHP 7.1 或 7.2。

解决方案是下载更新的驱动程序(https://github.com/Microsoft/msphpsql/releases 支持 7.2 但标记为 "technical preview")或降级到 PHP 7.0 版。

其他常见问题是:

  • 无法下载所需的额外内容Microsoft ODBC drivers
  • 混淆 x86 和 x64 版本的驱动程序(还有 ts/nts "thread safe" 和 "non thread safe")。将取决于您的 system/php 安装。

还看到 pecl 提供了 'preview' 版本的驱动程序:https://pecl.php.net/package/pdo_sqlsrv/5.0.0/windows

他们还提供了这个有用的描述:

The Microsoft Drivers for PHP for SQL Server are PHP extensions that allow for the reading and writing of SQL Server data from within PHP scripts. The SQLSRV extension provides a procedural interface while the PDO_SQLSRV extension implements PDO for accessing data in all editions of SQL Server 2008 R2 and later (including Azure SQL DB). These drivers rely on the Microsoft ODBC Driver for SQL Server to handle the low-level communication with SQL Server.