問題描述
我升級(jí)到 PHP 5.3,發(fā)現(xiàn)缺少 php_mssql.dll.在谷歌搜索了一下之后,似乎 5.3 已經(jīng)放棄了對(duì) mssql 的支持.所以我從微軟下載了驅(qū)動(dòng)程序,但我似乎無法讓它工作.
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/手冊(cè)/en/intro.mssql.php:
MSSQL 擴(kuò)展在使用 PHP 5.3 或更高版本的 Windows 上不再可用.SQLSRV,Microsoft 提供的 MS SQL 替代驅(qū)動(dòng)程序:? 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.
下載后,請(qǐng)按照此頁面上的說明進(jìn)行操作:
Once you downloaded that, follow the instructions at this page:
- 為 SQL Server 加載適用于 PHP 的 Microsoft 驅(qū)動(dòng)程序
簡而言之:
將驅(qū)動(dòng)程序文件放在您的 PHP 擴(kuò)展目錄中.
修改 php.ini 文件以包含驅(qū)動(dòng)程序.例如:
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
重新啟動(dòng) Web 服務(wù)器.
Restart the Web server.
另見(從該頁面復(fù)制)
- 系統(tǒng)要求(適用于 SQL Server 的 PHP 的 Microsoft 驅(qū)動(dòng)程序)
- 入門
- 編程指南
- SQLSRV 驅(qū)動(dòng)程序 API 參考(Microsoft Drivers for PHP for SQL Server)
SQLSRV 擴(kuò)展的 PHP 手冊(cè)位于 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:
通過將適當(dāng)?shù)?DLL 文件添加到 PHP 擴(kuò)展目錄和 php.ini 文件的相應(yīng)條目來啟用 SQLSRV 擴(kuò)展.SQLSRV 下載帶有幾個(gè)驅(qū)動(dòng)程序文件.您使用哪個(gè)驅(qū)動(dòng)程序文件將取決于 3 個(gè)因素:您使用的 PHP 版本,您使用的是線程安全的還是非線程安全的 PHP,以及您的 PHP 安裝是使用 VC6 還是 VC9 編譯器編譯的.例如,如果您運(yùn)行的是 PHP 5.3,您使用的是非線程安全的 PHP,并且您的 PHP 安裝是使用 VC9 編譯器編譯的,那么您應(yīng)該使用 php_sqlsrv_53_nts_vc9.dll 文件.(如果您使用 IIS 作為您的 Web 服務(wù)器,則應(yīng)使用使用 VC9 編譯器編譯的非線程安全版本).如果您運(yùn)行的是 PHP 5.2,您使用的是線程安全的 PHP,并且您的 PHP 安裝是使用 VC6 編譯器編譯的,那么您應(yīng)該使用 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.
驅(qū)動(dòng)程序也可以與 PDO 一起使用.
這篇關(guān)于由于 MSSQL 已被棄用,如何讓 SQLSRV 擴(kuò)展與 PHP 一起使用?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!