News Archive
PhpRiot Newsletter
Your Email Address:

More information

Supercharging PHP MySQL applications using the best API

Note: This article was originally published at Planet PHP on 20 April 7380.
Planet PHP

PHP MySQL developers are confronted with three PHP MySQL APIs. That is confusing. Since mid 2012 the PHP manual suggests not to use the oldest and original PHP MySQL extension any more to cure the situation. Please, swap out ext/mysql in favour of either ext/mysqli or PDO_MySQL. Why to upgrade is below. Read on, if you are a PHP beginner, your PHP application is still using mysql_* functions of ext/mysql or you are a PHP trainer.

As a PHP consumer, tease your software vendors by asking whether they use the state of the art APIs! Here is a cut&paste test question to ask your vendor: do you support secure SSL connections to MySQL?

History and features

PHP and MySQL go hand in hand. The original MySQL API (ext/mysql) is around since PHP 2.0. Many web sites still show examples of the original MySQL API (ext/mysql). This is amazing considering the feature comparison of the three PHP MySQL APIs. By the way, do you know this Quickstart guide on ext/mysqli that is in the PHP manual?

API feature comparison A ext/mysqli PDO_MySQL ext/mysql PHP version introduced 5.0 5.1 2.0 Year introduced 2003 2005 Last century Included with PHP 5.x Yes Yes Yes Development status Active Active Maintenance only Feature additions All new,
flagship All new,
given they fit PDO None since 2006 Lifecycle Active Active Long term deprecation announced Recommended for new projects Yes Yes No OOP Interface Yes Yes No Procedural Interface Yes No Yes API supports non-blocking, asynchronous queries with mysqlnd Yes No No Persistent Connections Yes Yes Yes "No pitfall" Persistent Connections Default, can be disabled No No API supports Charsets Yes Yes Yes API supports server-side Prepared Statements Yes Yes No API supports client-side Prepared Statements No Yes No API supports Stored Procedures Yes Yes No API supports Multiple Statements Yes Most No API supports Transactions Yes Yes No Transactions can be controlled with SQL Yes Yes Yes API supports SSL Yes Yes No API supports Compression Yes "/

Truncated by Planet PHP, read more at the original (another 17907 bytes)