Working with Microsoft SQL Server driver (php_sqlsrv.dll) for PHP on Windows

Posted: Jan 25, 2010  1 comments  

Average Rating

Tags
IIS
PHP
PHP extension
Sql Server
SQL Server Driver for PHP

Share this Post

I get a lot of forum posting in our IIS forum asking how to develop PHP application using Microsoft SQL Server. Today I am going to explain basics of developing PHP application on Microsoft SQL Server. Let me start by stating one thing, developing PHP application on Microsoft SQL Server is really easy. The extension which glues the two world namely PHP and Microsoft SQL Server is called ‘Microsoft SQL Server Driver for PHP’. Some important characteristics of this driver are:

This driver is replacement of old PHP MSSQL driver. So if you have enabled this extension, you may as well disable php_mssql.dll extension in your php.ini file. In order to disable the old MSSQL driver simply comment the below line in your php.ini file (put ‘;’ in the beginning of the line).

extension=php_mssql.dll

The old MSSQL driver is not supported by Microsoft as it takes dependency on some deprecated libraries, so it is a good idea to do the new development using new SQL Server driver. Also porting your existing application to the new SQL Server driver should be easy and is advisable from my side unless you are not planning any enhancement/development in that piece of code.

One can use Microsoft Web Platform Installer too to get the latest driver. The SQL Server driver can be found under ‘Database’ link inside ‘Web Platform’ tab. The installation comes with different version of driver to support different version of PHP as well as thread safe and non-thread safe appetite of it. The naming convention should tell you this. For example the DLL named ‘php_sqlsrv_53_ts_vc9.dll’ means this DLL should be used with thread safe version of PHP 5.3 built using VC9 compiler. Please use appropriate version otherwise PHP will not load the DLL at runtime. The installation also comes with a help file (CHM file) which contains lot of useful information pertaining to installation, usage as well as all the API well documented.

I hope this will help you getting started with developing PHP application on Microsoft SQL Server. Thanks for the patient reading and till we meet again ‘Good Bye’.

Thanks,

Don.