PHP
  Home arrow PHP arrow Building Object-Oriented Database Inte...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Building Object-Oriented Database Interfaces in PHP: Working with Multiple Data Access Objects
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 13
    2005-08-24

    Table of Contents:
  • Building Object-Oriented Database Interfaces in PHP: Working with Multiple Data Access Objects
  • Getting in touch with a DB Interface: A brief look at the "DBI Generator" class
  • Code generator in a nutshell: one class that generates another one
  • Some useful examples: a practical usage of the "DBIGenerator" class
  • Adding rows to both tables: working with multiple data access objects

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


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


    (Page 1 of 5 )

    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.

    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


       · Part three of the tutorial explains the advantages of working with multiple database...
       · Thanks again Alejandro, this series has helped me understand a concept that until...
       · Hello Jeff,Glad to hear from you again. It's important to know that this series...
       · It's such a good article.
       · Thank you for the kind words about my article. It's very much appreciated.Best...
       · Hi Alejandro, thanks a lot for these articles. Although a difficult subject (for...
       · Hello Matthijs,I feel very pleased of knowing that this series has been helpful...
       · Hi Alejandro I am by far no expert but have a fairly decent grasp of php and oop,...
       · Hello John,Thanks a lot for your kind words. I'm very pleased to know that my...
       · Hi Alejandro defently looking foward to them especially the caching one. If at some...
       · Hello John,Thank you for the message. Good to hear that the upcoming PHP...
       · Hello,This is a very interesting article, but I have a question. Lets say that...
       · Hello,Thank you for the comments on my article. They're much appreciated.With...
       · Okay, that makes sense. And in fact, it is what I did before you posted. Glad we...
       · Hello again,Regarding your question on your current project, even when I don't...
       · Hi Alejandro,Thank you for taking the time write an truly excellent article on...
       · Hello ShamzZ,Thank you for your kind comments on my PHP article; I'm glad to...
       · The DBIGenerator is awesome. I've been wanting to do that for a while but never took...
       · Hi again Sig,As I posted before, thank you for introducing your comments here....
       · Really enjoyed the article. I'm starting to dive into OO in PHP and this helped...
       · Hi Paul,Thank you for the kind comments on my PHP article. I indeed appreciate...
       · This series of Alejandro helps me complete a full blown, database driven website for...
       · Hi Roy,Thank you for the kind comments on my PHP article, and I'm glad to know...
     

       

    PHP ARTICLES

    - Authentication Scripts for a User Management...
    - Utilizing the Use Keyword for Namespaces in ...
    - Building a User Management Application
    - Working With Different Namespaces in PHP 5
    - User Management Explained: Overview
    - Using Namespaces in PHP 5
    - Database Security: Guarding Against SQL Inje...
    - Building a Modular Exception Class in PHP 5
    - Database and Password Security for Web Appli...
    - Handling MySQL Data Set Failures in PHP 5
    - Building Site Registration for Web Applicati...
    - Intercepting Customized Exceptions in PHP 5
    - Securing Your Web Application Against Attacks
    - Sub Classing Exceptions in PHP 5
    - Authentication for Web Application Security





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
    Stay green...Green IT