Chapter 20. Database Abstraction

In this lesson you will learn how to access different databases from PHP, using a single interface. Database abstraction is a very powerful technique; it allows you to write scripts for a nonspecific database back end, which you can then easily port simply by changing the connection parameters.

The PEAR DB Class

Many different database abstraction layers are available for PHP, but the one you will learn how to use in this lesson is the PEAR DB class. In Lesson 25, “Using PEAR,” you will find out more about PEAR—the PHP Extension and Application Repository—and some other useful classes it contains.

The DB class implements database abstraction, using PHP's database extensions, and it currently supports the ...

Get Sams Teach Yourself PHP in 10 Minutes now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.