[Part 2 of this post is here.]
The SQL Server Driver for PHP (also called the "sqlsrv" driver for it’s API prefix) has been available since July of 2008, but I still often see the "old" driver (the "mssql" driver) used to connect to SQL Server from PHP scripts. Many of the tutorials I come across and many of the questions I see in forums indicate that lots of people are still using the mssql driver even though it is no longer under active development. In this post I want to begin looking at some of the differences between the two drivers and perhaps gain an understanding of why the mssql driver continues to be used (although I have some good guesses). There are lots of comparison points between the mssql and sqlsrv drivers. I’ll break my comparison into two posts, focusing on high-level differences in this post and then dive into an API comparison in the next post.
I’ll start by stating the obvious: the mssql and sqlsrv drivers are not one and the same. Sorry, but I actually think that needed to be stated explicitly. I’m probably just picking nits, but I often see mssql and sqlsrv used interchangeably, or at least that’s what I think I see. Perhaps people are using mssql as a short form for Microsoft SQL Server and not the driver itself (or maybe I’m just easily confused), but the confusion makes me wonder if people are actually aware of the key differences:
· The sqlsrv driver is built, maintained, and supported by Microsoft. There have been two releases of the driver (v1.0 and v1.1), as well as cumulative updates to release improvements. Different versions of the binaries (depending on what version of PHP you are running) are available here: SQL Server Driver for PHP 1.1. The source code is available on Codeplex at http://sqlsrvphp.codeplex.com/.
· The mssql driver is a community-built driver. I’m not sure how recently this driver was updated or maintained as an official PHP extension, but as of the release of PHP 5.3, it is no longer available with PECL. A quick internet search turns up a few places to download the mssql driver, but none of them that I’ve found indicate that the driver is being actively maintained.
· The underlying technologies for the two drivers are different. (See Diagram 1 below.)
o The sqlsrv driver is built on ODBC, which is actively maintained by Microsoft and provides access to features in the latest releases of SQL Server.
o The mssql driver is built on DB Lib (i.e. it requires ntwdblib.dll) if you are running PHP on Windows. DB Lib is no longer supported by Microsoft
o If you are running PHP on Linux, the mssql driver is built on FreeTDS.
That last point brings up one last major difference: the mssql driver does provide connectivity to SQL Server from Linux. That said, it would appear that Microsoft is considering ODBC support on non-Microsoft platforms, which equates to support for the sqlsrv driver on Linux. See one of my earlier posts for more information: SQL Server Access From Linux - What Do You Think?
Those are the high-level differences between the mssql and sqlsrv drivers (next time I’ll look at the differences in the APIs). If you are using the mssql driver on Windows, I’d be interested in understanding why (as opposed to the sqlsrv driver).
Go to part 2 of this post.
Share this on Twitter