Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When using PHP on Windows, what is better (1) the native driver for SQL Server or (2) the PDO driver?

I am using PHP 5.3.6 on Windows and connecting to a SQL Server 2008 database.

According to the docs at MSDN there are two drivers for me to choose from.

php_sqlsrv_53_nts_vc9.dll

php_pdo_sqlsrv_53_nts_vc9.dll

The documentation on how to use each is great, but I'm not sure why I would use one over the other.

Can someone provide some insight on what the fundamental differences are (other than syntax) and why one is better than the other?

like image 717
Ralph M. Rivera Avatar asked Dec 04 '11 19:12

Ralph M. Rivera


1 Answers

The bonus to using PDO is that if your hosting environment changes to Linux or SQL Server is not available then there is very little that you will need to change. The connection string, where you specify what sort of database (SQL Server, MySQL, SQLite etc) would be the main if not the only change needed. (apart from how you format your queries)

like image 151
Marc Towler Avatar answered Oct 07 '22 06:10

Marc Towler