IIS7 上的 PHP,支持 (PDO) MS-SQL

标签 php sql-server iis-7

我正在运行一个 IIS 7 Windows 服务器,我的 phpinfo 配置命令的相关部分当前报告如下:

cscript /nologo configure.js ...... "--without-mssql" "--without-pdo-mssql" "--without-pi3web" ...... "--with-mcrypt=static"

我需要对我的服务器做什么才能看到上面的 with-mssql 而不是看到 without-mssql?

有人告诉我重新编译 PHP。这就是降压停止的地方。因为此 PHP 随 IIS 安装一起提供,所以我们以前不需要编译 PHP。重新编译...那是命令行的事吗?

最佳答案

Microsoft SQL Server 支持和扩展不再随 PHP 一起提供。要将 PHP 与 SQL Server 连接,您需要 Microsoft Drivers for PHP for SQL Server :

The Microsoft Drivers for PHP for SQL Server is a PHP 5 extension that provides data access to SQL Server 2005 and later versions including SQL Azure.

驱动程序的下载页面列出了四个可供选择的版本。咨询System Requirements页面以确定您需要哪个版本。 您必须为您的操作系统+SQL Server+PHP 版本组合安装正确的驱动程序

根据您选择的驱动程序,您还需要其中之一(这些必须单独安装):

  • SQL Server native 客户端
  • 用于 SQL Server 的 Microsoft ODBC 驱动程序 11

安装程序只是将文件提取到指定位置。您必须将这些文件放到 PHP 扩展目录中。这些文件是 PHP 扩展。文件名表示:

  • nts/ts -- 应该与非线程安全/线程安全版本的 PHP 一起使用
  • 54/55/56... -- 应与 PHP 版本 5.4、5.5、5.6...一起使用
  • sqlsrv/pdo_sqlsrv -- 提供过程接口(interface)/PDO接口(interface)

php.ini 文件中启用扩展,确保线程安全性和 PHP 版本匹配。

检查 phpinfo 以查看是否加载了扩展。测试 sqlsrv_connect("servername")new PDO("sqlsrv:server=servername") 以确保扩展正常工作。

关于IIS7 上的 PHP,支持 (PDO) MS-SQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9797951/

相关文章:

php - 需要在每个连接的基础上在 PHP/MySQL 中使用 UTC 时间戳转换

javascript - 为数据库查询结果的每个结果动态创建唯一的链接或按钮

iis-7 - 使用命令行按名称绑定(bind) SSL 证书

iis-7 - ASP Classic 应用程序中的 Multipart/form-data 和 UTF-8

PHP 注释代码帮助

php - 按存档文件中的页面属性对自定义帖子类型进行排序不起作用

sql-server - 多个实例的 Entity Framework 迁移策略

c# - 在应用程序中获取数据库服务器日期时间

SQL Server 加入顺序

nhibernate - IIS7 + NHibernate : Illegal operation attempted on a registry key that has been marked for deletion