安装/配置
在线手册:中文 英文
PHP手册

需求

Requirements for Win32 platforms.

The extension requires the MS SQL Client Tools to be installed on the system where PHP is installed. The Client Tools can be installed from the MS SQL Server CD or by copying ntwdblib.dll from \winnt\system32 on the server to \winnt\system32 on the PHP box. Copying ntwdblib.dll will only provide access through named pipes. Configuration of the client will require installation of all the tools.

This 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.

Requirements for Unix/Linux platforms.

To use the MSSQL extension on Unix/Linux, you first need to build and install the FreeTDS library. Source code and installation instructions are available at the FreeTDS home page: » http://www.freetds.org/

Note:

On Windows, the DBLIB from Microsoft is used. Functions that return a column name are based on the dbcolname() function in DBLIB. DBLIB was developed for SQL Server 6.x where the max identifier length is 30. For this reason, the maximum column length is 30 characters. On platforms where FreeTDS is used (Linux), this is not a problem.

Note:

On Windows, if you're using MSSQL 2005 or greater you must copy the ntwdblib.dll into the directory where you have installed php and overwrite the one thats already in there. This is due to the version distributed is old and outdated. Alternatively you can use the » http://msdn.microsoft.com/en-us/sqlserver/ff657782.aspx, ODBC, PDO_DBLIB or PDO_ODBC extensions, to talk to MSSQL.


安装/配置
在线手册:中文 英文
PHP手册
PHP手册 - N: 需求

用户评论:

mihabo at hotmail dot com (03-Mar-2010 11:56)

I have struggled a lot to make PHP connect to a MS SQL server from under a Linux (using FreeTDS).
I installed the latest FreeTDS and tried to use usual host:port to connect to a server.
Finally when I configured freetds.conf like that:

[mysrvalias]
        host = 192.168.17.17
        port = 1433
        tds version = 7.0

and used mysrvalias instead of the 192.168.17.17:1433, it worked!

dave at modernsignal dot com (23-Dec-2009 06:17)

On a relatively new install of Windows Server 2008, the dll MSVCR71.DLL was missing.  I was able to download it (search for "MSVCR71.DLL download") and put it in the system32 folder to get it to work.