_dbTable = $dbTable; return $this; } public function getDbTable() { if (null === $this->_dbTable) { $this->setDbTable('Application_Model_DbTable_Role'); } return $this->_dbTable; } public function save(Application_Model_Role $role) { $data = array('roleID'=> $role->getID() ,'groupID'=> $role->getGroupID() ,'title'=> $role->getTitle() ,'description'=> $role->getDescription() ); if (null === ($id = $role->getID()) ) { unset($data['roleID']); $this->getDbTable()->insert($data); } else { $this->getDbTable()->update($data, array('roleID = ?' => $id)); } } public function delete(Application_Model_Role $role) { if (null === ($id = $role->getID()) ) { return; } else { $this->getDbTable()->delete(array('roleID = ?' => $id)); } } public function find($id, Application_Model_Role $role) { $result = $this->getDbTable()->find($id); if (0 == count($result)) { return; } $row = $result->current(); $role->setID($row->roleID)->setGroupID($row->groupID)->setTitle($row->title)->setDescription($row->description); } public function fetchAll() { $resultSet = $this->getDbTable()->fetchAll(); $entries = array(); foreach ($resultSet as $row) { $entry = new Application_Model_Role(); $entry->setID($row->roleID)->setGroupID($row->groupID)->setTitle($row->title)->setDescription($row->description); $entries[] = $entry; } return $entries; } }