PHP Programming/dbal
From Wikibooks, the open-content textbooks collection
[edit] What is a database abstraction layer?
A database abstraction layer (dal) is a couple of functions or a class which deals with every aspects of database handling.
First of all you have a function to connect and to disconnect to/from the database. You also have some functions to submit a query, and to get the results and finally you need to have some error-handling functions too.
[edit] Why to use a dal instead of the regular php funcitons?
Of course you do not replace the php-functions, you just connect them to get a better performance when you need to develop your code, validate the data, etc...
If you use a really flexible dal, then you do not need to change every line of your code if you switch from one database type to the other.
[edit] How to write a dal?
There are several ready-to-use open-source dals available. The most common one is the PEAR:DB package which is already installed on the majority of the web servers.
You can find some less sophisticated dals in the source files of some well written open-source CMS sites also.