// set up our options
$opts = &PEAR::getStaticProperty('DB_DataObject','options');
$opts = array(
'class_location' => '/home/me/Projects/myapplication/DataObjects',
'class_prefix' => 'DataObjects_'
);
// loads the file: /home/me/Projects/myapplication/DataObjects/Person.php
// and checks that the class DataObjects_Person exists, and returns an
// instance of it.
$person = DB_DataObject::factory('person');
if ($person->get(12)) {
print_r($person);
} else {
echo "NO person 12 exists";
}
// it can also be used in a dynamically
class DataObjects_MyTable {
function anExample() {
$person = $this->factory('person');
// supported in version 1.7.2
$another_mytable = $this->factory();
$another_person = $person->factory();
}
} |