Ulf Wendel

PHP: mysqlnd to support PDO, mysqlnd in PHP 5.3

Dear MySQL and PHP users,

we have two good news for you. First, we are proud to announce that one year after the announcement to develop a new MySQL native driver for PHP (mysqlnd), the new driver has been committed into the 5.3 branch of the PHP project. PHP 5.3 is expected to be the next major release of PHP.

According to a poll on the PHP Internals development list the new driver is among the five most desired features for PHP 5.3. Thank you for your trust in mysqlnd! We will try to continue to listen to your whishes and are looking forward to hear back from you.

The second news is that we will strengthen our commitment into PHP by improving our support for PHP Data Objects (PDO). We will work on a PDO/mysqlnd driver, both for PHP 5.3 and PHP 6.0. Development starts in these days and will include QA, testing and documentation as we go forward.

We continue to describe mysqlnd as late beta and recommend it for development systems only. At the time of writing mysqlnd undercuts its predecessor in the number of known issues for ext/mysqli and ext/mysql according to our testing.

Our plan is have a Generally Available (GA) Release of mysqlnd used with ext/mysqli and ext/mysql ready for the first production version of PHP 5.3. To prepare a GA Release, we have allocated additional resources for improving the existing ext/mysqli and ext/mysql documentation.

What is mysqlnd?

The MySQL native driver for PHP (mysqlnd) is a superior alternative to the MySQL Client Libary (libmysql). The new driver is highly optimized for PHP due to the tight integration of mysqlnd with PHP’s internal infrastructure. This results in:

  • improved performance
  • less memory consumption for buffered result sets
  • new performance statistics for bottle-neck analysis
  • easier compilation because of no external dependencies

The new driver has been integrated into the PHP extensions:

  • ext/mysqli
  • ext/mysql

Both extensions can be compiled with support for libmysql – like ever since – or mysqlnd. That means you can switch between libmysql and mysqlnd at compile time. Support for PHP Data Objects (PDO) is planned, see above.

The usage of mysqlnd is transparent to the PHP application developer. No code changes are required for existing applications. The MySQL native driver for PHP (mysqlnd) can be used to connect to any MySQL Server 4.1 and above.

According to our internal QA and first user feedback, mysqlnd has reached a good level of stability. We call it late beta and recommend it for development systems only.

Which is the best driver for PHP?

Driver can be a misleading term for PHP. PHP consists of a language core plus extensions. A extensions implement an API for tasks that can’t be accomplished with the language cure. PHP offers three extensions (and thereby APIs) for communication with the MySQL Server:

  • PHP 5+: ext/mysqli
  • PHP 2+: ext/mysql
  • PHP 5+: PDO_MySQL

Our current flagship is ext/mysqli (MySQL Improved Extension). The mysqli extension allows you to access the functionality provided by MySQL 4.1 and above. For example, it includes support for Prepared Statement, Character Sets and Stored Procedures.

ext/mysql is the predecessor of ext/mysqli. Although this MySQL extension is compatible with MySQL 4.1 and greater, it doesn’t support the extra functionality that these versions provide. You can’t make full use of MySQL, if you use it. Please do not use it for new developments.

PDO_MySQL implements the PHP Data Objects (PDO) interface to access the MySQL Server from PHP. PDO is a data-access layer that was introduced with PHP 5.0.

Internally all three extensions use the MySQL Client Library (libmysql) on the C-level. ext/mysqli and ext/mysql have been modified to support the MySQL native driver for PHP, which is a drop-in replacement for libmysql. You can choose at compile time if ext/mysql and ext/mysql make use of mysqlnd or libmysql. See above regarding PDO_MySQL.

We kindly ask you to start using mysqlnd on your development systems, because we found it to be a superior alternative over libmysql. As a PHP application developer the use of mysqlnd and libmysql is transparent to you, which makes testing easy.

Where can I get more information?

Watch out for news on planetmysql.org and planet-php.net. The MySQL native driver is work in progress.

7 Comments