Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can PHP work with a MS SQL database

I work primarly with PHP & MySQL, but I have a potential client with a MS SQL and ASP setup. Due to some complicated reasons and offline software integration, they need to keep the databases in the same format, which means not moving to MySQL which would be my personal preference.

So the question is can I use PHP to access and manipulate an MS SQL database or am I screwed on this one?

Thanks in advance

like image 924
TH1981 Avatar asked Mar 23 '11 17:03

TH1981


1 Answers

Yes, you can. It depends on which version of PHP you're using, but if you're using PHP5+ you can use Microsoft's SQL Server Driver for PHP. Make sure you use version 2, which gives you the PDO functionality as well as the procedural style.

You can also use the PDO ODBC driver to access a SQL Server instance, but that approach is more buggy and I don't recommend it.

Finally you can use the PHP MSSQL library but that's even worse. Go with Microsoft's own solution if you can.

Edit: Oh, and there's also the DBLIB MSSQL PDO driver - stay away from that one too!

like image 153
Craig Avatar answered Oct 06 '22 01:10

Craig