The Web has matured and grown over the last decade and with it the need for more complex and dynamic sites. While storing information in a text file or simple database may have been suitable in the past, these days any serious application developer requires a firm knowledge of how to wield the relational database.
From the earliest versions of PHP, programmers have always been able to count on strong database support. However until the recent release of PDO there had been no standard way of interfacing with the multiple database drivers bundled with PHP. The lack of unified API has spawned several efforts to create database abstraction layers (DBAL). The primary goal of these efforts is to enable developers to write code that is not specific to the database back end being used, thereby enabling clients/users to deploy the application on whichever database platform they prefer.
The three most prominent full-featured database abstraction layers over the years have been AdoDB, PEAR::DB, and Metabase. In the last few years we have seen another very strong contender in the arena of database abstraction layers, and that is PEAR::MDB. This chapter is about MDB's second iteration—MDB2.
It all started when Lukas Smith, a PEAR developer, submitted a few patches to the existing DBAL, Metabase. At some point he and the Metabase author started discussing bringing Metabase into PEAR as a new package. The goal of the new package was to merge the functionality of Metabase with the API of the existing and popular PEAR::DB into a feature-rich and well-performing database abstraction library, leveraging the PEAR infrastructure. Thus began the life of MDB2's predecessor PEAR::MDB.
After a few years of work on PEAR::MDB, it became apparent that the decision to keep a similar API to that of Metabase and PEAR::DB created some design issues, which hampered the growth of MDB into a full-featured DBAL. Since PEAR::MDB had reached a stable state in PEAR, it was not possible to fix these API issues without breaking backwards compatibility, which was not an option. The solution was to take the lessons learned during the development of Metabase and MDB and apply them to a new package that would contain a well-designed and modern API. The new package became MDB2.