Userland database driver implementations

at 2010-07-09 in ExperimentsDatabases by friebe (0 comments)

Following a discussion we had about software packaging for our test, qa and live clusters (most of which run Debian Lenny, meaning it brings PHP 5.2.6 with the mssql extension, unfortunately unsuitable for ASE 15 / univarchar fields), we decided two things:

  1. We need to compile a more recent PHP version with sybase_ct ourselves
  2. We should investigate in more independence from installed system libraries and PHP extensions
The second point is really not a new decision, the XP Framework has a long history of userland implementations, reflection without the reflection library in PHP4 times, XML builders without ext/dom, the HTTP protocol without ext/curl or http_build_query or JSON without ext/json, to name just a few, and - more recently, FTP without ext/ftp, partially due to the fact that PHP didn't provide these functionalities at the time we implemented them and partially due to the fact that we couldn't count on the extensions being available everywhere we wanted to install and run the XP Framework.


So in general the strategy of the XP Framework is to be able to work with a more or less stock PHP, requiring only those modules we can be most sure of always having, ext/reflection, the Perl compatible regex functionality, sockets, files and the one or other hash function (md5, sha1, ...). We even provide an xp.ini file (and suggest adding PHP config per VirtualHost / Location) so that the system-wide PHP configuration doesn't need to be touched. This way, we can make our framework run on all versions from PHP 5.2.0 through PHP 5.3.x, wrapping around PHP bugs in earlier versions and providing snap-in functionality for extensions that might be missing.

The most recent additions to this "independence" strategy are pure userland implementations of the MySQL and TDS protocols, both of which are still in an experimental stadium but gaining robustness every day:

http://experiments.xp-forge.net/xml/browse?arena,mysqlx - MySQL 4+
http://experiments.xp-forge.net/xml/browse?arena,sybasex - Sybase / MSSQL

As the MySQL protocol is easier to implement we can already say so far that it's only about 10% slower than the native implementation - pulling 50 records from a MySQL server on the network with an example query took 10ms with the userland implementation, and 7ms with ext/mysql, PHP's implementation using the system's libmysql.

There's still some more (unit-)testing to be done, and maybe some performance tweaks, but as we see the drivers mature, we will probably provide them as snap-ins first (that is, if no Sybase or MSSQL extension is loaded, the userland implementation will be used instead) and eventually move to providing them as first pick, that way easing the dependencies from an installed TDS system library (e.g. FreeTDS, or the native Sybase drivers) and PHP's extension to essentially just stock PHP, and have it portable by default.



Subscribe

You can subscribe to the XP framework's news by using RSS syndication.


Categories

News
General
PHP5
Announcements
RFCs
Further reading
Examples
Editorial
EASC
Experiments
Unittests
Databases
5.8-SERIES

Related

Find related articles by a search for «Userland».