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

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

问题描述

我升级到PHP 5.3,并注意到缺少php_mssql.dll.稍作搜索后,似乎5.3放弃了对mssql的支持.因此,我从Microsoft下载了驱动程序,但似乎无法正常工作.

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.

我在Windows上.将文件解压缩到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/手册/zh/intro.mssql.php :

MSSQL扩展名在具有PHP 5.3或更高版本的Windows上不再可用. 可以从Microsoft获得SQLSRV,它是MS SQL的替代驱动程序:» http://msdn.microsoft.com/zh-cn/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.

另请参见(从该页面复制)

See Also (copied from that page)

  • System Requirements (Microsoft Drivers for PHP for SQL Server)
  • Getting Started
  • Programming Guide
  • SQLSRV Driver API Reference (Microsoft Drivers for PHP for SQL 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,以及您的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天全站免登陆