Study Guide: PHP Programming->dbal

What is a database abstraction layer?

A database abstraction layer (DBAL) 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.

Why to use a DBAL instead of the regular php functions?

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 DBAL, then you do not need to change every line of your code if you switch from one database type to the other.

How to write a DBAL?

Most users should not be writing their own DBAL, since there are several ready-to-use open-source DBALs available. One of the benefits of a DBAL is to make code more reusable, and writing your own DBAL (unless it achieves wide acceptance in the PHP community) is counterproductive. The most common one is the PEAR:DB package[1] which is already installed on the majority of web servers.

You can find some less sophisticated DBALs in the source files of some well written open-source CMS sites also.


  This article uses material from the Wikipedia page available here. It is released under the Creative Commons Attribution-Share-Alike License 3.0.



Connect with defaultLogic
What We've Done
Led Digital Marketing Efforts of Top 500 e-Retailers.
Worked with Top Brands at Leading Agencies.
Successfully Managed Over $50 million in Digital Ad Spend.
Developed Strategies and Processes that Enabled Brands to Grow During an Economic Downturn.
Taught Advanced Internet Marketing Strategies at the graduate level.

Manage research, learning and skills at Create an account using LinkedIn to manage and organize your omni-channel knowledge. is like a shopping cart for information -- helping you to save, discuss and share.

  Contact Us