SQLSRV driver vs. PDO driver for PHP with MS SQL Server

后端 未结 3 1733
旧巷少年郎
旧巷少年郎 2020-12-15 20:04

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 p

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-15 21:11

    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.

提交回复
热议问题