While writing some PHP Training materials for Pale Purple, I thought I'd add an updated guide on PHP and database access. I've already done one on PEAR::DB, but PEAR::MDB2 is it's successor and has a slightly different API.... and as PEAR::DB is now deprecated, it's probably about time I rewrote it anyway.
What is PEAR::MDB2?
MDB2 is yet another database API for PHP. It's written in PHP, so can be used in a cross platform manner. Because it's written in PHP, it's not going to be as 'fast' as the PDO library, however it's portability may make up for that.
Compared to the native bundled legacy PHP libraries (mysqli_*, pgsql_*, sqlite_*, mysql_), changing which database you are using can be as simple as changing the connection parameters to your database. The PDO libraries offer the same advantage, however they require PHP5.
Getting started
It's recommended you install it using the Pear installer, like the following :
pear install MDB2 pear install MDB2_Driver_$db
Where $db would be one of e.g. mysql, pgsql, sqlite, ori8, mssql etc.