id = $id; $db =& MDB2::singleton(); $this->table = 'category'; // Go ahead and query as much as we can $sql = "SELECT * FROM ".$this->table." WHERE id = ".$db->quote($this->id).";"; $this->arr_db = $db->getRow($sql); $this->arr_keys = array_keys($this->arr_db); unset($this->arr_keys['id']); } public function __get($var) { if(in_array($var, $this->arr_keys)) { return $this->arr_db[$var]; } else { return $this->$var; } } public function __set($var, $value) { $db =& MDB2::singleton(); if(in_array($var, $this->arr_keys)) { $arr_update = array($var => $value); $db->autoExecute($this->table, $arr_update, MDB2_AUTOQUERY_UPDATE, "id = ".$db->quote($this->id)); $this->$var = $value; } } } ?>