哪一个更快更轻-mysqli& PDO

问题描述:

我正在使用 MySQL PHP5 .我知道不再维护古老的mysql_*函数,社区已经开始弃用过程.所以我决定离开mysql_*.问题是去哪里?我正在寻找更轻松,更简单,更快捷的方法.有人告诉我这些(mysqliPDO)中的哪一个是

I am using MySQL with PHP5. I got to know that ancient mysql_* functions are no longer maintained and community has begun the deprecation process. So I decided to move away from mysql_*. The question is where to? I am looking for lighter, simpler and faster way. Somebody tell me which among these (mysqli and PDO) is;

  1. 更快
  2. 易于学习和编写代码
  3. 占用更少的空间和内存

注意:这两个入门级的教程链接将很有帮助.

PDO vs. MySQLi: Which Should You Use?

PDO MySQLi 均提供了面向对象的API ,但MySQLi也提供了 提供了过程式API –使新手更容易 理解.如果您熟悉本机PHP MySQL驱动程序,则可以 将发现迁移到程序化MySQLi接口要容易得多.在 另一方面,一旦掌握了PDO,就可以将其与任何数据库一起使用 你渴望!

Both PDO and MySQLi offer an object-oriented API, but MySQLi also offers a procedural API – which makes it easier for newcomers to understand. If you are familiar with the native PHP MySQL driver, you will find migration to the procedural MySQLi interface much easier. On the other hand, once you master PDO, you can use it with any database you desire!

最终,PDO轻松赢得了这场战斗.支持十二 不同的数据库驱动程序(十八个不同的数据库!)并命名 参数,我们可以忽略很小的性能损失,并习惯于 其API.从安全角度来看,只要 开发人员以应有的方式使用它们.

Ultimately, PDO wins this battle with ease. With support for twelve different database drivers (eighteen different databases!) and named parameters, we can ignore the small performance loss, and get used to its API. From a security standpoint, both of them are safe as long as the developer uses them the way they are supposed to be used.

因此,如果您仍在使用MySQLi,也许是时候进行更改了!

So if you’re still working with MySQLi, maybe it’s time for a change!

PDO与MySQLi的比较:您应该使用哪个? -由Dejan Marjanovic

PDO vs. MySQLi: Which Should You Use? - By Dejan Marjanovic

希望这会有所帮助.