在 SQLSRV 驱动程序与 PDO 驱动程序之间进行选择时,我应该考虑哪些因素(对于带有 MS SQL 服务器的 PHP)?
What considerations should I take into account when choosing between SQLSRV driver vs. PDO driver (for PHP with MS SQL server)?
我看到了之前的 Stackoverflow 帖子(在 Windows 上使用 PHP 时,哪个更好(1)SQL Server 的本机驱动程序或(2)PDO 驱动程序? )但答案似乎有点缺乏并且没有没有提到 这篇文章.
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.
我正在寻找一个全面的和最新的(例如,SQLSRV 驱动程序是否仍然只适用于 Windows?)答案,程序员可以将其称为资源.
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 允许您编写合理的 DB 中立的代码.
PDO allows you to write you code to be reasonably DB-neutral.
如果你想要真正的数据库中立,你会想要使用一个完整的数据库抽象层,比如 NotORM-- 使用普通 PDO,您仍然需要注意 SQL 语法差异,但至少您的基本 PHP 代码将与 DB 无关.
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.
DB 中立现在似乎并不重要——如果你使用 SQL Server,那么你可能被告知这是必需的,没有别的——但是你无法预测事情会如何改变未来,所以如果选择是在 DB 中立驱动程序和 DB 特定驱动程序之间,并且您没有任何其他理由偏爱,那么选择中性驱动程序......它会让生活变得很多如果您的公司被接管并且新老板想使用 Oracle 作为数据库,则更容易!
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!
此外,因为它是 DB 中立的,所以 PDO 在 PHP 社区中更标准且更广为人知.与使用 MSSQL 驱动程序相比,您将从在线站点(如本站点)获得更多有关 PDO 的帮助.
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.
这篇关于SQLSRV 驱动程序与用于 PHP 和 MS SQL Server 的 PDO 驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!