What considerations should I take into account when choosing between SQLSRV driver vs. PDO driver (for PHP with MS SQL server)?
I saw this previous Stackoverflow post ( When using PHP on Windows, what is better (1) the native driver for SQL Server or (2) the PDO driver? ) but the answer seems a bit lacking and doesn’t mention all the benefits of using the SQLSRV driver as mentioned in this article.
I’m looking for a comprehensive and up-to-date (eg. is it still the case that SQLSRV driver is only available for Windows?) answer that programmers can refer to as a resource.
PDO allows you to write you code to be reasonably DB-neutral.
If you want truly DB-neutral, you’d want to use a full DB abstraction layer like NotORM — with plain PDO, you’d still need to be careful about SQL syntax difference, but at least your basic PHP code would be DB-neutral.
Being DB-neutral may not seem important now — if you’re using SQL Server, then you’ve probably been told that’s what is required and nothing else — but you can’t predict how things will change in the future, so if the choice is between a DB-neutral driver and a DB-specific driver, and you don’t have any other reason for a preference, then go with the neutral one…. it’ll make life a lot easier if your company gets taken over and the new boss wants to use Oracle as the DB!
Also, because it’s DB neutral, PDO is more standard and more well-known in the PHP community. You’ll get a lot more help with PDO from sites online (like this one) than with the MSSQL driver.