created by tomfmason at 2008-12-12 16:44:38
A simple example of php's call method
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
<?php
class Table {
    //an associative array of the fields from your db
    var $fields = array();
    //the prefix for the fields
    var $prefix = "your_prefix_";
    public function __get($name) {
        if (!array_key_exists($name, $this->fields) && array_key_exists($this->prefix . $name, $this->fields)){
            return $this->fields[$this->prefix . $name];
        }
    }
}
//$your_array is the array of fields from your database
$your_table = new Table();
$your_table->fields = $your_array()
#the field name from the orginal array minus the prefix
echo $foo->field_name;
?>