|
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.
| Field | Type | Notes |
| id | integer | Primary key Auto increment |
| name | text |
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 ]
| Comments: | ||
| PHP ORM for Shared Servers | Dan Blaisdell | 03/03/09 11:09 |
| Php Object Generator | Jake | 09/13/05 20:37 |
| EZPDO: an easy ORM framework for PHP5 | xman101 | 07/21/05 16:25 |
| More to it - article is incomplete | Milos Radenovic | 05/27/05 10:20 |
| Database Tables | olivier | 02/25/05 20:06 |
| RE: good basic design? | jojo reyes | 01/25/05 01:45 |
| Abstracting the database layer | jojo reyes | 01/24/05 22:48 |
| RE: agreed | Shankar | 01/17/05 13:21 |
| good basic design? | crivera | 12/08/04 18:49 |
| RE: Breaks fundamental design principles | mmorales | 05/28/04 10:08 |
| RE: Breaks fundamental design principles | Benjamin Smith | 04/24/04 03:29 |
| RE: Breaks fundamental design principles | Art Hundiak | 04/06/04 13:48 |
| RE: Breaks fundamental design principles | Ferdinand Beyer | 04/03/04 06:41 |
| Breaks fundamental design principles | Jack Slocum | 03/27/04 02:32 |
| Good basic design principles | Jared White | 03/20/04 22:56 |
| RE: agreed - maturity needed | Kieran Mathieson | 03/15/04 14:11 |
| RE: agreed | les | 03/13/04 09:13 |
| Performance | Lars | 03/12/04 07:42 |
| agreed | Cyril Doussin | 03/11/04 02:52 |
| Code Reuse? Existing Alternatives | kellan | 03/10/04 12:46 |
| Well written | Surjit Madiwalar | 03/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. | ||


