Compare mysqli or PDO – what are the pros and cons?

Technology CommunityCategory: PHPCompare mysqli or PDO – what are the pros and cons?
VietMX Staff asked 4 years ago

Let’s name some:

  • PDO is the standard, it’s what most developers will expect to use.
  • Moving an application from one database to another isn’t very common, but sooner or later you may find yourself working on another project using a different RDBMS. If you’re at home with PDO then there will at least be one thing less to learn at that point.
  • A really nice thing with PDO is you can fetch the data, injecting it automatically in an object.
  • PDO has some features that help agains SQL injection
  • In sense of speed of execution MySQLi wins, but unless you have a good wrapper using MySQLi, its functions dealing with prepared statements are awful. inserts – almost equal, selects – mysqli is ~2.5% faster for non-prepared statements/~6.7% faster for prepared statements.