Home arrow PHP arrow Building Object-Oriented Database Interfaces in PHP: Working with Multiple Data Access Objects

Building Object-Oriented Database Interfaces in PHP: Working with Multiple Data Access Objects

In previous articles in this series, we examined the concept of database interfaces, and saw source code for a "DBIGenerator" class. Working with multiple DB interfaces permits the accomplishment of several operations on many tables at the same time. Alejandro Gervasio demonstrates the power of this concept, with examples.

TABLE OF CONTENTS:
  1. Building Object-Oriented Database Interfaces in PHP: Working with Multiple Data Access Objects
  2. Getting in touch with a DB Interface: A brief look at the "DBI Generator" class
  3. Code generator in a nutshell: one class that generates another one
  4. Some useful examples: a practical usage of the "DBIGenerator" class
  5. Adding rows to both tables: working with multiple data access objects
By: Alejandro Gervasio
Rating: starstarstarstarstar / 15
August 24, 2005

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Introduction

Here we are again. Welcome to the third part of the series "Building Object-Oriented Database Interfaces in PHP." I'm pretty sure that you've been working for a while with the concept of database interfaces explained in my previous articles, playing around with the source code defined for the already familiar "DBIGenerator" class.

In order to offer a brief summary of what we've learned until now about database interfaces, let's quickly review some key concepts. Undoubtedly, the most critical issue is to understand the why of the existence of such a programming structure.

Through the previous articles, we've seen that at times it is much better to implement a set of classes that sit between the database logic and the PHP application logic. This establishes a single access point to the data, and creates an efficient structure (the classes themselves) to wrap up core DML statements into "packages" that perform one-row operations on database tables. Definitely, the advantages of working with these classes become more evident when used with multiple DB interfaces, because it's possible to accomplish several operations on many tables at the same time, by using each class tied to a database table.

Having this concept in mind, I've developed a class named "DBIGenerator," which takes care of generating the proper DB interface for a given database table, building a class that represents the structure of the table in a logical way. Indeed, the "DBIGenerator" class behaves as a real "database access object factory," returning a new object that allows you to work directly on tables, executing single-row DML statements.

At this point, I firmly believe that you properly understand the basic theory behind database interfaces. Thus, it's time to make another leap forward in the learning process.

Either you've been developing your own set of DB Interface classes or simply expect to see several examples about its possible uses in Web applications. In this third part I will hopefully offer a practical approximation, by showing some concrete cases where the real power of DB Interfaces is clearly demonstrated. Are you ready to work with database interfaces in PHP? Fine. Let's get started.



 
 
>>> More PHP Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
   

PHP ARTICLES

- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 9 - Follow our Sitemap

Dev Shed Tutorial Topics: