There are 2 supported drivers that allow connections to Microsoft SQL Server databases. The first, mssqlnative allows connections from Windows Clients to Microsoft SQL Server databases versions 2008 and up, and uses the Microsoft Native Client libraries. The second, mssql allows connections from Unix based clients using the freetds libraries.
Connecting to SQL server 2003 creates a difficulty There is no support for native client connections, and the alternative method, using php_mssql.dll was removed in PHP 5.3. The only alternative is to use a generic ODBC driver that does not require the Microsoft Native Client libraries.
This is the preferred driver for connecting to a SQL server database from Windows clients.
This driver was contributed by Microsoft and provides connections to SQL server databases greater than SQL Server 2003. It requires PHP version 5.3 or greater, Microsoft native client software and the appropriate PHP driver.
Sequences are supported in native mode in SQL Sever 2012, and emulated in earlier versions.
The default behavior for the PHP mssqlnative driver is to return date/time fields as a PHP dateTime object, that looks like this:
[RequiredDate] => DateTime Object ( [date] => 1996-08-01 00:00:00.000000 [timezone_type] => 3 [timezone] => America/Denver )
However, in order to improve portability, the default behaviour of the ADOdb mssqlnative driver is to return the date as a string:
[RequiredDate] => 1996-08-01 00:00:00.000000
In order to return the dateTime as an object, the following action is required:
$db = ADONewConnection('mssqlnative'); $db->setConnectionParameter('ReturnDatesAsStrings',false); $db->connect('SERVER\SQLEXPRESS','user','password','NORTHWND');
You can set the character set to UTF-8 using:
$db = ADONewConnection('mssqlnative'); $db->setConnectionParameter('characterSet','UTF-8'); $db->connect('SERVER\SQLEXPRESS','user','password','NORTHWND');
This is the preferred driver for connecting to a SQL server database from Linux/Unix clients. This driver provides access to Microsoft SQL Server databases from unix systems via Freetds
This driver was the primary connection method to SQL Server databases up to PHP Version 5.2. The windows dll associated with this driver (php_mssql.dll) was removed from the standard PHP distribution in PHP Version 5.3. There is no community support for this driver.
This driver provides undocumented portability extensions to the Unix mssql driver
This driver appears to provide Unicode enhancements to the mssql driver