Sr. Web Developer
mediabistro.com
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume

A Practical Approach to Object-Relational Mapping in PHP
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.
[ Next Page ]

[Page 1]  [Page 2]  


Comments:
PHP ORM for Shared ServersDan Blaisdell03/03/09 11:09
Php Object GeneratorJake09/13/05 20:37
EZPDO: an easy ORM framework for PHP5xman10107/21/05 16:25
More to it - article is incompleteMilos Radenovic05/27/05 10:20
Database Tablesolivier02/25/05 20:06
RE: good basic design?jojo reyes01/25/05 01:45
Abstracting the database layerjojo reyes01/24/05 22:48
RE: agreedShankar01/17/05 13:21
good basic design?crivera12/08/04 18:49
RE: Breaks fundamental design principlesmmorales05/28/04 10:08
RE: Breaks fundamental design principlesBenjamin Smith04/24/04 03:29
RE: Breaks fundamental design principlesArt Hundiak04/06/04 13:48
RE: Breaks fundamental design principlesFerdinand Beyer04/03/04 06:41
Breaks fundamental design principlesJack Slocum03/27/04 02:32
Good basic design principlesJared White03/20/04 22:56
RE: agreed - maturity neededKieran Mathieson03/15/04 14:11
RE: agreedles03/13/04 09:13
PerformanceLars03/12/04 07:42
agreedCyril Doussin03/11/04 02:52
Code Reuse? Existing Alternativeskellan03/10/04 12:46
Well writtenSurjit Madiwalar03/10/04 05:40
 

If you are looking for help, please post on the appropriate forum here. Your questions will be answered much more quickly.

Add A Comment:

Name:

Email:

Subject:

Message:

To reduce spam posts, messages are now manually approved

You are not [logged in]. That means your account will not get credit for this post.