PHP 5.3 and Microsoft SQL Server

by justin carlson on 09/02/2009
Microsoft recently released an updated SQL server driver that works with PHP 5.3.x.  I needed to make some changes to a very old app that uses MSSQL and PEAR::DB so I decided to grab this and try it out.  Of course it didn't work out so well or I wouldn't be posting this.

Their new driver (Microsoft SQL Server Driver for PHP 1.1) uses sqlsrv_connect() instead of mssql_connect(), sqlsrv_query() instead of mssql_query(), etc, etc. So of course the old PEAR::DB mssql driver wasn't going to do anything but throw undefined function exceptions all day. It also, by default, returns date objects instead of strings for all query results. The old app didn't know what to make of that, which means I saw a lot of 1969's floating around.

All I needed to do is make a one line code change in this old app, but I couldn't fire it up and test it without the database working.

I could go back to 5.2.x just to make this code change, and then go back to 5.3.x, but what a pain. Long story short, I created a PEAR::DB driver for sqlsrv and completed the code change.

If you find yourself in the same situation, you can grab it here: sqlsrvdriver.tar

NOTE: I only did what I had to do, so query, insert, updates have been tested, everything else hasn't been tested.

Related errors:
Fatal error: [db_error: message="DB Error: extension not found" code=-25 mode=return level=notice prefix="" info=" [DB Error: extension not found] **

Fatal error: Call to undefined function mssql_connect() in

Trackback

Trackback URL for this entry: http://www.tehuber.com/trackback.php?id=20090902164931414

No trackback comments for this entry.
PHP 5.3 and Microsoft SQL Server | 0 comments | Create New Account
The following comments are owned by whomever posted them. This site is not responsible for what they say.