Database Abstraction With PHP - Alphabet Soup (
Page 2 of 11 )
I'll start with the basics -
what the heck is a database abstraction layer anyhow?
A database
abstraction layer is a database-independent software interface. As the name
suggests, it's a layer of abstraction over the actual database access methods
and allows developers to deal with different databases without radically
altering their code on a per-database basis.
By placing a layer of
abstraction between the database and the developer, the database abstraction
layer insulates the programmer from database implementation details. If you
initially write a script to talk directly to, say, Oracle and later need to have
it work with another database server, you will usually have to rewrite all the
database-specific parts. If you use a database-independent API, you can port
your script over with very little surgery required.
PHP's database
abstraction layer comes courtesy of PEAR, the PHP Extension and Application
Repository (http://pear.php.net). In case you didn't know, PEAR is an online
repository of free PHP software, including classes and modules for everything
from data archiving to XML parsing. When you install PHP, a whole bunch of PEAR
modules get installed as well; the DB class is one of them.