简体   繁体   English

准备好的语句:MySQLi 还是 PDO?

[英]Prepared statements: MySQLi or PDO?

I'm using mySQL database and found out that using Prepared statements offer lots of benefits.我正在使用 mySQL 数据库并发现使用 Prepared 语句提供了很多好处。 However by browsing Stackoverflow I noticed that every expert encourages to use PDO, but no one talks about MySQLi.但是通过浏览 Stackoverflow 我注意到每个专家都鼓励使用 PDO,但没有人谈论 MySQLi。 As far I have understood, PDO supports multiple databases, if thats not the concern, why PDO is preferred over mySQLi?据我了解,PDO 支持多个数据库,如果这不是问题,为什么 PDO 比 mySQLi 更受欢迎? Thanks谢谢

PDO is more mature. PDO 更成熟。 It offers more features and is easier to use.它提供了更多功能并且更易于使用。 It has fewer bugs.它的错误更少。 The choice has nothing to do with the number of drivers supported by PDO;选择与 PDO 支持的驱动程序数量无关; you would need to rewrite your SQL anyway if you decided to change the RDBMS.如果您决定更改 RDBMS,则无论如何都需要重写 SQL。

PDO is simply a much better extension for communication with the database. PDO 只是一个更好的与数据库通信的扩展。

PDO is interface for accessing databases, so you can use various drivers. PDO 是访问数据库的接口,因此您可以使用各种驱动程序。 This mechanism gives you abstraction, so it's preferrable.这种机制为您提供了抽象,因此更可取。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM