PHPBuilder - A Practical Approach to Object-Relational Mapping in PHP Page 2



RSS Twitter
Articles Application Architecture

A Practical Approach to Object-Relational Mapping in PHP - Page 2

by: PHP Builder Staff
|
March 8, 2004

Background
Suppose your company breeds hippos for the army. Some are used as beasts of burden. Others are equipped with weapons, like pie throwers, and spit projectors. Your company doesn't install the weapons, just the sockets the weapons plug into. Armed hippos can have more than one mount point.
First, we'll create the hippos table, with the fields id and name.
FieldTypeNotes
idintegerPrimary key
Auto increment
nametext 
Now some PHP. For simplicity, methods not directly related to the topic we're discussing have been omitted.

<?php
class Hippo 
{
    var 
$id null;
    var 
$name null;
    
//Load record from DB
    
function load($id
    {
        ...
    }
    
//Save record to DB
    
function save() 
    {
        ...
    }
}
?>
Hippo is a "business classes," that is, a class describing something meaningful to nontechnical people in the business. Some classes do not correspond to business entities. For example, classes for database objects, like Table, Record, and Field, might not mean anything to the average sales representative. However, he or she will understand what a Hippo is, and will know that they have id numbers and names.

« Previous Page
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|
10
Next Page »

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:

Comment:



Comment:

(Maximum characters: 1200). You have characters left.