Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
711 views
in Technique[技术] by (71.8m points)

php - Which one is faster and lighter - mysqli & PDO

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. faster
  2. easy to learn and code
  3. consumes less space and memory

Note: Tutorial links in beginner level for these two will be helpful.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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 .


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...