由于 MSSQL 已被弃用,如何让 SQLSRV 扩展与 PHP 一起使用? [英] How do I get the SQLSRV extension to work with PHP, since MSSQL is deprecated?

查看:22
本文介绍了由于 MSSQL 已被弃用,如何让 SQLSRV 扩展与 PHP 一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我升级到 PHP 5.3,发现缺少 php_mssql.dll.在谷歌搜索了一下之后,似乎 5.3 已经放弃了对 mssql 的支持.所以我从微软下载了驱动程序,但我似乎无法让它工作.

I upgraded to PHP 5.3, and noticed that php_mssql.dll is missing. After googling a bit, it seems that 5.3 has dropped support for mssql. So I downloaded the drivers from microsoft, but I can't seem to get it to work.

我在窗户上.在我的 PHP 5.3 的 ext 目录中解压文件后,我需要做什么?

I am on windows. What do I need to do, after I unzip the files in the ext directory of my PHP 5.3?

推荐答案

引用 http://php.net/手册/en/intro.mssql.php:

MSSQL 扩展在使用 PHP 5.3 或更高版本的 Windows 上不再可用.SQLSRV,Microsoft 提供的 MS SQL 替代驱动程序:» http://msdn.microsoft.com/en-us/sqlserver/ff657782.aspx.

The MSSQL extension is not available anymore on Windows with PHP 5.3 or later. SQLSRV, an alternative driver for MS SQL is available from Microsoft: » http://msdn.microsoft.com/en-us/sqlserver/ff657782.aspx.

下载后,请按照此页面上的说明进行操作:

Once you downloaded that, follow the instructions at this page:

简而言之:

将驱动程序文件放在您的 PHP 扩展目录中.
修改 php.ini 文件以包含驱动程序.例如:

Put the driver file in your PHP extension directory.
Modify the php.ini file to include the driver. For example:

extension=php_sqlsrv_53_nts_vc9.dll  

重新启动 Web 服务器.

Restart the Web server.

另见(从该页面复制)

SQLSRV 扩展的 PHP 手册位于 http://php.net/manual/en/sqlsrv.installation.php 并提供以下安装:

The PHP Manual for the SQLSRV extension is located at http://php.net/manual/en/sqlsrv.installation.php and offers the following for Installation:

通过将适当的 DLL 文件添加到 PHP 扩展目录和 php.ini 文件的相应条目来启用 SQLSRV 扩展.SQLSRV 下载带有几个驱动程序文件.您使用哪个驱动程序文件将取决于 3 个因素:您使用的 PHP 版本,您使用的是线程安全的还是非线程安全的 PHP,以及您的 PHP 安装是使用 VC6 还是 VC9 编译器编译的.例如,如果您运行的是 PHP 5.3,您使用的是非线程安全的 PHP,并且您的 PHP 安装是使用 VC9 编译器编译的,那么您应该使用 php_sqlsrv_53_nts_vc9.dll 文件.(如果您使用 IIS 作为您的 Web 服务器,则应使用使用 VC9 编译器编译的非线程安全版本).如果您运行的是 PHP 5.2,您使用的是线程安全的 PHP,并且您的 PHP 安装是使用 VC6 编译器编译的,那么您应该使用 php_sqlsrv_52_ts_vc6.dll 文件.

The SQLSRV extension is enabled by adding appropriate DLL file to your PHP extension directory and the corresponding entry to the php.ini file. The SQLSRV download comes with several driver files. Which driver file you use will depend on 3 factors: the PHP version you are using, whether you are using thread-safe or non-thread-safe PHP, and whether your PHP installation was compiled with the VC6 or VC9 compiler. For example, if you are running PHP 5.3, you are using non-thread-safe PHP, and your PHP installation was compiled with the VC9 compiler, you should use the php_sqlsrv_53_nts_vc9.dll file. (You should use a non-thread-safe version compiled with the VC9 compiler if you are using IIS as your web server). If you are running PHP 5.2, you are using thread-safe PHP, and your PHP installation was compiled with the VC6 compiler, you should use the php_sqlsrv_52_ts_vc6.dll file.

驱动程序也可以与 PDO 一起使用.

这篇关于由于 MSSQL 已被弃用,如何让 SQLSRV 扩展与 PHP 一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆