PHP 中的 ADOdb 和 PDO 有什么区别?
两者似乎都尝试使用 PHP 中的数据库使其变得更简单。两者似乎都提供了对不同数据库类型(如 MySQL、SQLite 等)的抽象。ADOdb
和 PDO 之间有什么区别?
Both seem to try making it simpler using a database in PHP. Both seem to provide an abstraction over different database types like MySQL, SQLite, etc.
What are the differences between both ADOdb and PDO?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
自版本 5.1 起,PDO 已成为 PHP 中的标准。 (它也可以通过 PHP 5.0 中的 PECL 扩展使用)大多数托管服务提供商都会启用它。 AdoDB 不是标准扩展。
另外,我相信 PDO 驱动程序是“PHP 原生的”:它们构建在 PHP 本身构建的相同库之上,并使用相同的底层例程来进行内存管理等操作。因此,PDO 可能比 AdoDB 更轻量。
根据此基准测试,AdoDB 比 PDO 慢得多:(固定链接)
https://gist.github.com/tony-landis/31483
当然,您应该考虑这对于您的用例是否重要到更喜欢 PDO。
PDO is standard in PHP as of version 5.1. (It is also available with a PECL extension in PHP 5.0) Most hosting provides will have it enabled. AdoDB is not a standard extension.
Also, I believe the PDO drivers are "PHP-native": they are built on top of the same libraries that PHP itself was built on, and use the same underlying routines for things like memory management. So potentially, PDO is more lightweight than AdoDB.
According to this benchmark, AdoDB is considerably slower than PDO: (fixed link)
https://gist.github.com/tony-landis/31483
Of course, you should consider whether this is important enough for your use case to prefer PDO or not.
从技术角度来看,最显着的区别是 PDO 是本机扩展,从 PHP 5 开始,始终以其快速的编译形式包含在 PHP 中。 ADODb 也有一个扩展,但您必须先在 PHP 中安装它。这是支持 PDO 的有力论据,因为基于它的产品可能在更多环境中运行得更快。
ADOdb 比 PDO 支持更多的数据库。
From a technical perspecitve, the most notable difference would be that PDO is a native extension and, from PHP 5 on, always included in PHP in its fast, compiled form. There is an extension for ADODb as well but you have to install it in PHP first. This is a strong argument in favour of PDO because products based on it are likely to run faster in more environments.
ADOdb supports a larger number of databases than PDO.
嗯,我认为这可以归结为偏好。 ADOdb 更适合那些习惯 Microsoft 风格的数据库访问 (ADO) 的人,而 PDO 更像“PHP”,并且也是 PHP 主流的一部分,而 ADOdb 则处于边缘地位。
最终,这将取决于您的目标数据库是什么(ADOdb 支持更多)以及您喜欢哪种语言风格。就我个人而言,我喜欢 PDO,它适合我的需求。
Well, I think it boils down to preference. ADOdb is more geared towards people who are used to the Microsoft style of Database access (ADO) and PDO is more "PHP" like and also part of the mainstream of PHP versus ADOdb which sort of sits off to the side.
At the end of the day, it would based on what your target DB is (ADOdb supports more) and what sort of language style your prefer. Personally, I like PDO and it suits my needs.
PDO 是原生的并且相当快。
ADOdb 是一个更丰富的库,甚至还有 ORM(对象关系映射)之类的东西。
对我来说,PDO 的一大缺点是,当它出错时,调试起来很糟糕,因为没有 PHP 源代码。当我调试一些复杂的代码时,我能看到正在执行的确切 SQL 的唯一方法是 PDO 驱动程序本身的子类......
当然,这都是意见!
PDO is native and pretty fast.
ADOdb is a richer library and even has things like ORM (Object Relational Mapping).
For me the big downside of PDO is it's horrible to debug when it goes wrong as there's no PHP source for it. When I was debugging some complicated code the only way I could see the exact SQL that was being executed was the subclass the PDO driver itself...
It's all opinion though of course!