What is a Database Abstraction Layer?

What is a Database Abstraction Layer?

A database abstraction layer is a set of PHP code that allows you to use a common syntax for interacting with different kinds of databases. Instead of having to learn the vagaries of the various native PHP database functions, you can use the same function names, with the same calling syntax, taking the same kinds of parameters and returning the same types of results and errors, to communicate with any number of different types of databases.

By using a database abstraction layer, you can easily take a component from one application, perhaps designed to work with PostgreSQL, and reuse that component in a different application, designed to work with an Oracle database. Although you might need to tweak the SQL statements used in that component, none of the PHP code would need to be modified.

Abstraction layers also make it very easy to implement logging or debugging functionality for all database interaction because the PHP functions that handle database interactions are centralized. Rather than have calls to pg_query or mysql_query littered throughout the application, you'll have a single function to which all queries are passed that allows you to intercept those queries and log them to a file, or do some sort of debugging.



Professional PHP5 (Programmer to Programmer Series)
Professional PHP5 (Programmer to Programmer Series)
ISBN: N/A
EAN: N/A
Year: 2003
Pages: 182

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net