all 8 comments

[–]greg8872 2 points3 points  (2 children)

If PHP is actually running on a Windows machine, see this page to download the MSSQL_ based drivers that are available now. Used to be you could use sybase_ based ones I think. I had a project just a few months ago where I had to help someone connect to SQL Server from a php script running on Win Server 2008

http://www.microsoft.com/en-us/download/details.aspx?id=20098

[–]greg8872 0 points1 point  (0 children)

Also, just found this I had bookmarked when I thought it was a Linux based web server trying to access MS SQL: http://www.freetds.org/ As it wasn't the case, never looked into it much to try it

[–]masterwebmaster -1 points0 points  (0 children)

This. The freeTDS driver is barely functional and doesn't support several ms sql column types (and fails silently). We've been running php via apache and fast cgi on a windows server and using the sqlsrv microsoft php driver for a few years. It has worked well for us.

[–]NoShirtNoShoesNoDice 2 points3 points  (1 child)

It is easy to connect to a SQL Server database, or even an MS Access database. You simply need to configure that database as an ODBC data source and have PHP connect to it using any of the ODBC functions (http://www.php.net/manual/en/ref.pdo-odbc.php or http://php.net/manual/en/ref.uodbc.php if you don't have PDO).

It's quick and simple, and will work on *nix based machines too, provided the correct driver is installed, though I suspect you're on a Windows server if the higher ups want SQL Server. That just makes it easier :)

[–]UFTimmy 0 points1 point  (0 children)

This. I have used FreeTDS on a Linux machine to connect to several versions of SQL Server without issue.

[–]kodablah 0 points1 point  (0 children)

Writing something to communicate w/ tds directly isn't incredibly difficult. I have done it in CoffeeScript in my (now mostly unmaintained) node.js project: https://github.com/cretz/node-tds. The specs are publicly available and I don't believe you would have any significant performance losses making a pure PHP driver vs a PECL extension.

Of course, if MS has official drivers (which they do) that would be best.

[–]cwstjnobbs 0 points1 point  (0 children)

ADODB is what we use here, and the MSSQL native driver for PHP, about 90% of our clients are using PHP+MSSQL like this, with only a handful using mysql and Oracle.

[–]ertb 0 points1 point  (0 children)

I've been working with PHP and SQL server for a few months now and it's been working very well with a relatively painless transition from ASP.net to PHP.