class Example {
var $id;
var $name;
function Example($id, $name){
$this->id = $id;
$this->name = $name;
}
function setId($id){
$this->id = $id;
}
}
class ExampleDao extends BaseDao {
function getAll(){
return parent::getList("select * from nodes", null, function($idx, $row) {
return new Example($row["id"], $row["name"]);
});
}
function load($id){
return parent::getSingle("select * from nodes where id = %1\$s", array($id), function($row) {
return new Example($row["id"], $row["name"]);
});
}
function update($example){
return parent::executeQuery("update nodes set name = '' where id = -1", null, function($result, $link){
return $result;
});
}
function insert(& $example){
return parent::executeQuery("insert into nodes", null, function($result, $link) use ($example){
$id = mysql_insert_id($link);
$example->setId($id);
return $result;
});
}
}
$exampleDao = new ExampleDao();
$list = $exampleDao->getAll());
$exampleObject = $exampleDao->load(1));
$exampleDao->update($exampleObject);