What is the difference between MySQL, MySQLi and PDO?


Question

What is the difference between MySQL, MySQLi and PDO?

Which one is the best suited to use with PHP-MySQL?

1
123
2/13/2016 2:38:13 AM

There are (more than) three popular ways to use MySQL from PHP. This outlines some features/differences PHP: Choosing an API:

  1. (DEPRECATED) The mysql functions are procedural and use manual escaping.
  2. MySQLi is a replacement for the mysql functions, with object-oriented and procedural versions. It has support for prepared statements.
  3. PDO (PHP Data Objects) is a general database abstraction layer with support for MySQL among many other databases. It provides prepared statements, and significant flexibility in how data is returned.

I would recommend using PDO with prepared statements. It is a well-designed API and will let you more easily move to another database (including any that supports ODBC) if necessary.

94
5/15/2019 7:05:26 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon