最近因為一些安全的問題,要把原本的程式升級到 PHP 5.3。原本想說可以無痛升級的,但是試了才知道,如果資料庫是使用 SQL Server 的話,就會很麻煩了! 在 PHP 5.3 以後就不再支持 SQL Server 了,因為微軟自己跳下來做了!(詳情請看:http://msdn.microsof
最近因為一些安全的問題,要把原本的程式升級到 PHP 5.3。原本想說可以無痛升級的,但是試了才知道,如果資料庫是使用 SQL Server 的話,就會很麻煩了!
在 PHP 5.3 以後就不再支持 SQL Server 了,因為微軟自己跳下來做了!(詳情請看:http://msdn.microsoft.com/en-us/sqlserver/ff657782.aspx)
除此之外,原本的 mssql_xxx 的 function 也不再支援,全部換成 sqlsrv_xxx 的Function。(http://www.php.net/manual/en/book.sqlsrv.php)
以下說明一下我的更新方式:
1. 下載 Microsoft Drivers 3.0 for PHP for SQL Server:http://www.microsoft.com/en-us/download/details.aspx?id=20098
在這邊有 SQLSRV20.EXE 以及 SQLSRV30.EXE。其中 SQLSRV30.EXE 是支援 SQL Server 2010 的,所以如果你是使用 SQL Server 2008,就下載 SQLSRV20.EXE 即可。
2. 安裝 SQLSRV for PHP
下載完後解開,將所有的 DLL 複製到 PHP 下的 ext 目錄。然後設定 php.ini。
在我的設定中,我是使用 php_sqlsrv_53_nts_vc9.dll。他的命名規則如下:
- _53_ :PHP 5.3,如果你是用 PHP 5.4 的話,就要使用 _54_ 的 DLL。
- _nts_ :Non-thread-safe,因為我是使用 FastCGI,所以使用 non thread safe,如果你是用 apache module 或是 IIS ISAPI 模式,就要使用 _ts_ 的 DLL。
- _vc9_ :使用 Microsfot Visual C++ v9 Compiler 的。
除了這個之外,如果你連接資料是使用 PDO 的方式,則要使用有 _PDO_ 的 DLL。
3. 設定 PHP.ini
只要加入 extension=php_sqlsrv_53_nts_vc9.dll 即可。
4. PHP 程式
因為我是使用 ADOdb Database Abstraction Library for PHP,所以只要修改 DB type 從 mssql 改為 mssqlnative 即可。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Zend Studio 13.0.1
Powerful PHP integrated development environment

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Atom editor mac version download
The most popular open source editor