Which one is faster and lighter - mysqli & PDO

后端 未结 3 792
孤独总比滥情好
孤独总比滥情好 2020-12-16 19:34

I am using MySQL with PHP5. I got to know that ancient mysql_* functions are no longer maintained and community has begun the

相关标签:
3条回答
  • 2020-12-16 20:17

    Along with the above question, here is a comparison chart;

    enter image description here

    And the information at Why you Should be using PHP’s PDO for Database Access is really helpful.

    0 讨论(0)
  • 2020-12-16 20:22

    About Performance

    While both PDO and MySQLi are quite fast, MySQLi performs insignificantly faster in benchmarks - ~2.5% for non-prepared statements, and ~6.5% for prepared ones. The MySQL extension was even faster.

    0 讨论(0)
  • 2020-12-16 20:30

    PDO vs. MySQLi: Which Should You Use?

    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!

    Summary

    DataBase Support

    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.

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

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

    Hope this helps .

    0 讨论(0)
提交回复
热议问题