There are (more than) three popular ways to use MySQL from PHP.
Connection :
// PDO
// mysqli, procedural style
// mysqli, object oriented style
API Support :
Both PDO and MySQLi provides an object-oriented approach, but MySQLi provides a procedural way also like old mysql extension. New users may prefer MySQLi because of procedural interface which is similar to old mysql extension, So the migrating from the old mysql extension is easier. But after mastering in PDO, you can use it with any database you like.
Database Support :
The main advantage of PDO over MySQLi is its database driver support. PDO supports 12 different drivers and MySQLi supports MySQL only.
To get the list of all drivers that PDO supports, use following code:
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.
PDO Drivers ¶Table of Contents ¶ |
Monday, 17 October 2016
What is the difference between MySQL, MySQLi and PDO?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment