Finally a working SQL Server Driver for PHP 5.3
Update: I’ve started an IIS Tutorial Series on Talking to SQL Server with PHP on IIS which contains more details of this installation.
It’s been a while since I’ve touched on the issue of having PHP 5.3 talk to a MS SQL Server on IIS (without using ODBC or other connection methods). Last time I’ve mentioned that Microsoft has an official SQL Server Driver (v1.0) for PHP to talk to a SQL Server only to find that it doesn’t work for PHP pre-v5.3, which, we didn’t really need anyway because PHP already came with a MS SQL Library driver (which was removed from 5.3) that somewhat works.
However, after starting to play around with PHP 5.3 with SQL Server again I’ve noticed that Microsoft finally release v1.1 of the SQL Server Driver, one that was stated to work with PHP 5.3 on IIS. Lo and behold, I was finally able to get it to work. Even better, the package also came with an offline documentation on installing the driver and the whole API Reference. Very nice. For those who are interested, here is the documentation online, the lo-bandwidth version (no MS Frames):
SQL Server Driver v1.1 for PHP
Note that if your SQL Server is on another server from the PHP server, you’ll also need to install the SQL Native Client data access library on the PHP server. (If it is on the same server, the installation of SQL Server already installs this package.) It is highly recommended to use the latest version that works with SQL Server 2008. It took me a while to find it (the 2005 version link is rampantly posted everyhere), but you can find it officially here:
Microsoft SQL Server 2008 Feature Pack, August 2008
Near the bottom of the page you’ll find “Microsoft SQL Server 2008 Native Client”. Get the one that’s appropriate for your machine. Despite it saying 2008, it should be backwards compatible with earlier versions of SQL Server. I’ve tried it as far as SQL Server 2000 (on IIS 6.0) and was able to connect and query successfully (I haven’t tested for limitations and such, if any.)
And there you have it. The official method to talk to a MS SQL Server on IIS with PHP 5.3, straight from Microsoft themselves.
Updated: October 09, 2009
The version of the SQL Driver 1.1 that was released in August was a preview release version. Microsoft officially released the final version of SQL Server Driver 1.1 on October 6th.
Glad you enjoy the new driver. (I work in the group that produces the driver.)
I would like to point out there is a newer version of the SQL Server Driver for PHP. The date of this post is 9/27, so I’m not sure you’re aware that we released the final version on 10/6. It is at the same link you have in the message. That link before went to a preview release, or CTP as we call it. The final release is a higher quality release overall.
I would also like to point out there is a newer version of the SQL Server 2008 Native Client available, from April 2009, at http://www.microsoft.com/downloads/details.aspx?familyid=B33D2C78-1059-4CE2-B80D-2343C099BCB4.
Thanks, and if you have problems, please let us know on our MSDN forum so we can help.
Jay,
Thanks for the personal notification of the final version of the SQL Server Driver. Now that you mentioned it, indeed I was using the CTP version. I’ve updated to the latest and haven’t run into any issues yet.
I’m glad that Microsoft is making a lot of progress in adding support for more open source projects such as PHP. Having a high quality driver for SQL Server in PHP definitely gives non-.NET programmers (like me) more confidence to producing more reliable PHP web solutions in enterprises that mainly use SQL Server for their internal software.
Keep up the good work!