Home arrow PHP arrow Building Object-Oriented Database Interfaces in PHP: Abstracting Database Tables

Building Object-Oriented Database Interfaces in PHP: Abstracting Database Tables

Welcome to part two of the series "Building Object-Oriented Database Interfaces in PHP." In the previous article, I offered complete coverage of the role that database interfaces play in Web applications, highlighting the immediate benefits of having a centralized mechanism for accessing, processing and verifying data, within an object-oriented environment. The "DBIGenerator" class I showed for demonstration purposes in the first article doesn't scale well in real applications. In this article, we will start solving its problems with a revamped version of the class.

TABLE OF CONTENTS:
  1. Building Object-Oriented Database Interfaces in PHP: Abstracting Database Tables
  2. Turning back time: a quick look at the older "DBIGenerator" class
  3. Working with multiple database interfaces: improving the "DBIGenerator" class
  4. Getting closer: a detailed look at the "generate()' method
  5. Updating and deleting a row: the "update()" and "delete()" methods
  6. Spotting the differences: the new "DBIGenerator" class in practice
By: Alejandro Gervasio
Rating: starstarstarstarstar / 13
August 17, 2005

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Introduction

Without having to necessarily mess up things with some concepts inherent to theory, we might generally conceive database interfaces as a logical representation coded within a class of a database table, where each table field is represented as a class data member. By following this generic rule on a given database table, we're able to build programmatically a class that contains all of the core DML statements required to manipulate table rows, using the methods provided by the class, in this way acting as single access points to the table data.

Stepping back to the first article, I've shown a "DBIGenerator" class that quickly creates DB interface classes, spawning the corresponding objects to provide access to a given database table. As you probably remember, this class doesn't scale well in real applications, since it works with a hard-coded database table and fields, thereby limiting significantly its flexibility and portability.

In order to solve these relevant issues, this second part will be the starting point for defining a revamped version of the "DBIGenerator" class, which, as we'll see in short order, will be powerful enough to be implemented successfully in the creation of DB interfaces.

Confronted with this scenario, it's time to put our coding abilities to the test. Let's go!



 
 
>>> 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: