SQL Server & PHP

This is a driver for CodeIgniter 1.7.2 to give support for SQL Server 2005 onwards (including SQL Server 2008).

I tested this on an old copy of thread-safe PHP 5.2.2 using the threadsafe version of the php_sqlsrv.dll driver, and it worked fine. It does state PHP 5.2.4 as a requirement, but I didn't run into any problems: your mileage may vary. The driver should also support PHP 5.3 if you are using the latest version of Microsoft's driver (version 1.1). Make sure that you read the requirements section in the Windows Help File (CHM) that comes with the driver, since you may need to get the Microsoft SQL Server 2008 Native Client (sqlncli10.dll) in order for it to work (regardless of which version of SQL Server you are running).

Known Issues

  1. This driver will probably NOT be compatible with version 1.0 of the php_sqlsrv.dll driver. Please consider upgrading your DLL first (the download links are below).
  2. ->num_rows() can be a bit of a pain. It needs a specific cursor type to work (which is detailed in the manual). It should work by default since I have set it to SQLSRV_CURSOR_STATIC, but I don't know yet if it will cause any performance issues. If you don't need to use the ->num_rows() function within sqlsrv_result.php I suggest changing this back to the default of SQLSRV_CURSOR_FORWARD.
  3. UTF-8 — The driver will connect using the UTF-8 charset if you set it as such within your config. From what I have read, the UTF-8 support only works when you use parameterised queries, which doesn't really 'fit' with how CodeIgniter goes about active record. For the time being, this will likely be broken - I haven't had chance to test it yet.

Links

Downloads

Thanks


Last Modified: 12th January 2010.