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

安装

The MSSQL extension is enabled by adding extension=php_mssql.dll to php.ini.

To get these functions to work, you have to compile PHP with --with-mssql[=DIR] , where DIR is the FreeTDS install prefix. And FreeTDS should be compiled using --enable-msdblib .

Warning

MS SQL functions are aliases to Sybase functions if PHP is compiled with Sybase extension and without MS SQL extension.


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

用户评论:

Dave (25-Jan-2010 09:25)

Linux users: I had to set the TDSDUMP and TDSCONFDUMP environment variables in my apache init script in order for freetds/mssql connections to work:

In my /etc/init.d/httpd file:
export FREETDSCONF=/usr/local/freetds/etc/freetds.conf
export SYBASE=/usr/local/freetds
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$SYBASE/lib
export TDSDUMP=/var/log/freetds/tdsdump-apache_log
export TDSDUMPCONF=/var/log/freetds/tdsdumpconf-apache_log

Make sure apache can write to the TDSDUMP directory.

(Using FreeTDS 0.82, PHP 5.2.9)

mirko dot steiner at slashdevslashnull dot de (29-Sep-2009 11:36)

PHP msdblib niggle encountered

In configuring your new version of PHP to work with FreeTDS 0.82, you may encounter:
configure: error: Directory /usr/local/freetds-0.82 is not a FreeTDS installation directory
PHP tests for a FreeTDS installation by looking for files that FreeTDS no longer installs. To assure PHP that FreeTDS is installed, create two files where FreeTDS was installed e.g.:
$ touch /usr/local/freetds-0.82/include/tds.h
$ touch /usr/local/freetds-0.82/lib/libtds.a
The file that needs to be changed is used by autoconf when the distribution tarball is constructed. Cf. revision 1.13 of PHP source file config.m4. (12 June 2008)

(http://www.freetds.org/news.html)

jonatasvenancio at gmail dot com (03-Mar-2009 07:07)

Finally i did it.

I could make the connection with MS-SQL:
1 - I downloaded the new version of ntwdblib.dll like we already saw at the others posts.
2 - I actived the php_mssql.dll in php.ini (the DLL must be in your extension dir)
3 - Restarted apache.
4 - Got my MS-SQL name instance (in my case was SQLEXPRESS because i was using MS-SQL Express Version and didn't change the default configuration).
5 - I did my connection file.

#################
<?php
$conn
= mssql_connect("ADMIN-PC\SQLEXPRESS", "usuario", "senha") or die ("erro ao conectar");

// Admin-PC is the name of my computer and SQLExpress is the name of MS-SQL Instance).
// usuario is a user that i created on SQL server with this command.
// SP_AddLogin 'user', 'password'
// after that i used this onde SP_AddUser 'user'
// you can change fot the user you want.
// I cound't use the defaullt user of MS-SQL, but with this one the connection worked.

?>

I hope this can help you.

Sorry for the english.
I'm brasilian.
Ven?ncio

Matt Mason (09-Jul-2008 06:42)

Had a problem compiling PHP with --with-mssql=/usr/local/freetds , kept saying that it wasn't a valid FreeTDS directory...

Check that when you install FreeTDS from source, that it actually puts the required files from the source directory to where the installation directory was specified, so to fix:

cp [tds source]/include/tds.h /usr/local/freetds/include
cp [tds source]src/tds/.libs/libtds.a /usr/local/freetds/lib

{in this example I installed FreeTDS to /usr/local/freetds}

This may make it a little easier for some else too.