Ulf Wendel

PHP: PDO_MYSQLND 1.0.2-alpha released

I am glad to announce the availability of the first alpha version of PDO_MYSQLND. PDO_MYSQLND is a PHP PDO driver for MySQL based on the MySQL native driver. PDO_MYSQLND 1.0.2-alpha is available for download on http://downloads.mysql.com/forge/pdo_mysqlnd_preview. Please read the announcement and check the MySQL Forge project page on PDO_MYSQLND for further information.

What is PDO_MYSQLND?

PDO (PHP Data Objects) is a data-access abstraction layer for PHP. PDO consists of a core and a rich set of database specific drivers. Traditionally there has been one PDO driver for MySQL called PDO_MYSQL. PDO_MYSQL is a community developed and community driven PDO driver. PDO_MYSQLND is a new PDO driver for MySQL based on it. PDO_MYSQLND is developed by MySQL and will be maintained by MySQL.

Under the hood, on the C-level, PDO_MYSQL does use the MySQL Client Library (libmysql). PDO_MYSQLND is an improved version of PDO_MYSQL which uses the MySQL native driver for PHP (mysqlnd) instead of the MySQL Client Library. Note that the use of either one is transparent to the PHP user and transparent to existing applications. The MySQL native driver for PHP is highly optimized and integrated into the internal PHP workings. We believe it to be a superior choice. Also, compiling PDO_MYSQLND is easier as no external libraries need to be installed.

The PHP extensions ext/mysqli (the recommended flagship) and ext/mysql (which does not support all MySQL 4.1+ functionality) have already been updated to allow you to compile them either against the MySQL Client Library (libmysql), like ever since, or the new MySQL native driver for PHP (mysqlnd). Now we are working on a PDO MySQL driver which supports both backend libraries – PDO_MYSQLND. PDO_MYSQLND 1.0.2alpha can be compiled only against mysqlnd. Support for the MySQL Client Library (libmysql) will be added for the first beta version.

Is it any better?

That is an excellent question! PDO_MYSQL and PDO_MYSQLND are roughly on the same level. The preview release of PDO_MYSQLND has already undercut the number of test failures in PDO_MYSQL slightly and the alpha continues to do so.

The following things have changed since we released the preview version:

  • Returns integer variables for integer columns, other native types like float continue to be returned as string due to PDO limitations
  • All memory leaks from the preview have been fixed – two left which are in PDO_MYSQL as well and might be PDO (not driver) issues
  • Due to new tests the code coverage is around 85% – that is +50% compared to PDO_MYSQL
  • Internal cross-platform testing on some 25 build machines has started and shows very promising results
  • Internal integration testing against several MySQL versions on the above mentioned 25 build machines has started
  • Windows build works on first systems (sorry, no binary yet!)
  • 94.9% of the tests passed with the 1.01-alpha vs. 94.2% with the 1.01-preview on a x86_64 box – ok, no big deal 🙂

(‘09.05.2008 – looks like we ship the the old test set with the alpha 🙁‘)

As you see we still focus on improving the stability. Test results are not bad but nevertheless we do not recommend using PDO_MYSQLND in production environments.

The one and only change on the API level is that PDO_MYSQLND now returns integer variables for integer columns whenever possible. We would like to return double for float columns but PDO does not support this, see also Request for Comments: PDO version 1 improvements. Therefore we have to continue with the old pattern of converting everything to string.

The next steps

We have been hoping to release a windows binary together with the alpha version but we decided to give “release often” the precedence over “never adapt your plans”. The plan for the next steps is as follows:

  • Release a windows binary – and of course test it, which is the hard part
  • Add support for the MySQL Client Library and make it behave the same way as mysqlnd – the choice of the backend library must be transparent for the end user
  • Fix all ~25 open PDO_MYSQL driver bugs (in PDO_MYSQLND) from [bugs|pecl].php.net
  • And of course QA: improve code coverage, improve test results

Why don’t you add new fancy features?

The PDO API is pretty much set. PDO tries to provide a uniform API to access databases. There is not much room for changes. Though, if you want any, please tell us. This is your chance to make us work on what you need!

As I’m at it – please participate to this initiative – Request for Comments: PDO version 1 improvements.

Enjoy!

3 Comments