Quick Comparison between PDO (PHP Data Objects) and MySQli

Pdo Vs MySqli

Quick comparison between PDO and MySQL.

1) MySQLi supports only MySQL database where as PDO supports different database systems like Microsoft SQL Server, MySQL, PostgreSQL etc.

2) PDO supports named paramaters which makes it flexible and easier. MySQLi doesn’t support named parameters. MySQLi provides question mark parameter binding and we must keep track of paramater order.

3) PDO::quote() not only escapes the string, but it also quotes it. In MySQLi, mysqli_real_escape_string() will only escape the string. you need to manually apply the quotes.

4) PDO has a dedicated function to get single column value
Where as MySQLi doesn’t have any.

5) Error Handling: PDO has a built in class to handle the errors.
PDO::errorInfo() returns an array of error information about the last operation performed.

6) Both PDO and MySQLi supports prepared queries which helps preventing SQL injection security issues.

7) Both PDO and MySQLi offer an object-oriented API, but MySQLi also offers a procedural API – which makes it easier for newcomers to understand. On the other hand, once you master PDO, you can use it with any database.


Leave a Reply