require_once 'DataObject.php'; class Person extends DataObject { protected $table = 'people'; protected $database_fields = array ( 'id' => 'person_id', 'name' => 'person_name', 'birthdate' => 'person_birthdate' ); }
$person = new Person(); $person->name = 'John Doe'; $person->birthdate = '1990-01-01'; $person->save(); $person = Person::getById(1); echo $person->name;In this example, we create a new `Person` object, set its `name` and `birthdate` properties, and save it to the database. We then retrieve the `Person` object with an `id` of `1` and output its `name`. The DataObject library is part of the PEAR package repository.