It is not a secret but an obvious thing that the most popular database backend for majority websites is mysql. Maybe you even know about recent split of MySQL into several forks,
due to Oracle aquiring Sun ("MySQL" trademarked branch is now under Oracle). Some notable forks are: MariaDB (led by "Monty" from the MySQL A.B. ) main differences are - focus on the high performance MyISAM engine, added transactions support for MyISAM (Aria engine), Percona - open development and support for XtraDB (replacement for InnoDB), Drizzle - more focused on "cloud" model, HailDB - library for embedded InnoDB.
With such a "forky" condition there is no warranty with compatability , when you use original libraries to access another kind of server, while the protocol itself is very well stable, it is better idea to create versatile way to access any kind of server, without binding PHP extensions to specific client library, and therefore let users have more freedom with switching one server/client libs to another kind, without getting lots of warnings in their logs about header/library mismatches for every mysql_connect() function.
PHP has 3 different extensions for accessing MySQL-like database:
- mysql - oldest one, offers basic functionality, supported by most software
- mysqli - mysql improved, rework of mysql, offers better performance and extended functionality (recommended but not used by all software, notably WordPress does not using mysqli)
- PDO_mysql - PHP Data Object class
All those 3 link with libmysqlclient.so.16 (or .15 if you have mysql 5.0).
Behold , PHPs own static extension for accessing MySQL-like DB - mysqlnd (MySQL Native Driver) , yes, its included into main tree, since PHP 5.3 and possibly will be default for PHP 6
Why ?
- It is included into PHP source tree, therefore you dont need to have mysql-client and mysql-client-dev installed
- It is not using any abstractions, the SQL data are available to Zend Engine directly, therefore there is less RAM hogged for general use (yet beware of enormous outputs that are larger that memory_limit)
- It is same license (PHP license)
- It is reusing PHP's internals, therefore its better optimized and has no overhead (mysql-common) on disk
- Internal statistics
Why not?
- It is still in "dev" state (if you affraid of things that are tagged so)
- It does not support old authentification (MySQL 4.0 and earlier, you may have new server, but if your databases are old, you may still have old style password hashes)
- Lack of compression and ssl (both are under development) (does matter if your SQL server is remote)
- Not included yet (as i know) into any binary distribution (but available in gentoo's .ebuild, so if you have gentoo - you can play with USE+="mysqlnd" )
- Mostly designed for UTF8 collations, if your db server has older style latin1, considner to convert, I dont seen any problems with my latin1_swedish_ci tables though..
Caveats?
- localhost connection assume socket, rather than TCP, therefore its mandratory to set pdo_mysql.default_socket, mysql.default_socket, mysqli.default_socket paths in php.ini
- On old databases there can be still old (pre 4.1) password hashes in mysql.users table, even if you have shiny new MySQL-like server.
You may have a test now, with Gentoo, or with compiling yourself , passing --with-mysql=(shared,)mysqlnd (likewise for mysqli and pdo_mysql) or you may wait for future, but _you are prepared_ now ;)
Comments ?
Post new comment