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
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- 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...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: