A few years ago Microsoft took a great initiative and made a SQL Server driver for PHP (only on Windows, but it's a start).
They have kept working on it and it's pretty good. The latest version is 3.0 but it came with some bad news. It is dependent on the SQL Server Native Client 11.0 (2012), which is not compatible with Windows XP/2003.
I decided to compile my own version that did not care which version of the SQL Server Native Client was installed. There are plenty of companies like mine that still have numerous XP desktops and 2003 servers.
If you use this build and attempt to access features introduced in the latest version on XP/2003, they will most likely not work, since they utilise the 2012 Native Client, which will not be present.
What you get is driver version 3.0 which has a fix to a memory leak, that should be compatible with existing code.
Downloads
- 12 October 2012: A new update with a bug fix when getting column names containing characters from languages like Greek, French, Russian and Japanese etc is here:
- php_sqlsrv 3.0.2 for php 5.4 and 5.3
I built it with VC10, so you might need to install the x86 VC++ 2010 redistributable package from Microsoft: here.
- Download unofficial php driver 3.0.0 here:
It's never a good idea to look at the source code of things you like - since I had to look, my new list of things to do includes writing a new version of this driver. It is a wrapper around the ODBC API, and has no business making strict dependencies on any version of the SQL Server Native Client. It should even work with SQL Server 6, because there is an ODBC driver for that too. Furthermore, it's a pretty ugly bit of code and every update is likely to introduce new bugs. It's still a better choice than using the PHP ODBC driver, as it's much faster in returning data.
Microsoft's official downloads are here:
SQL Server Native Clients are here: