From 25ac1a8e603fdaab8dd3851a7c8fd4fb353cc548 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 9 Feb 2011 01:12:05 +0100 Subject: Alle Mapper angelegt, Script update --- application/models/RightRolesMapper.php | 67 +++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'application/models/RightRolesMapper.php') diff --git a/application/models/RightRolesMapper.php b/application/models/RightRolesMapper.php index baaed21..4bac541 100644 --- a/application/models/RightRolesMapper.php +++ b/application/models/RightRolesMapper.php @@ -2,7 +2,74 @@ class Application_Model_RightRolesMapper { + + protected $_dbTable; + public function setDbTable($dbTable) + { + if (is_string($dbTable)) { + $dbTable = new $dbTable(); + } + if (!$dbTable instanceof Zend_Db_Table_Abstract) { + throw new Exception('Invalid table data gateway provided'); + } + + $this->_dbTable = $dbTable; + + return $this; + } + + public function getDbTable() + { + if (null === $this->_dbTable) { + $this->setDbTable('Application_Model_DbTable_Person'); + } + + return $this->_dbTable; + } + + public function save(Application_Model_RightRoles $rightroles) + { + + $data = array('roleID'=> $rightroles->getRoleID() ,'rightID'=> $rightroles->getRightID() ); + + if (null === ($id = $rightroles->getID()) ) { + unset($data['id']); + $this->getDbTable()->insert($data); + } else { + $this->getDbTable()->update($data, array('id = ?' => $id)); + } + } + + public function find($id, Application_Model_RightRoles $rightroles) + { + $result = $this->getDbTable()->find($id); + if (0 == count($result)) { + return; + } + + $row = $result->current(); + + $rightroles->setRoleID($row->roleID)->setRightID($row->rightID); + } + + public function fetchAll() + { + $resultSet = $this->getDbTable()->fetchAll(); + $entries = array(); + foreach ($resultSet as $row) { + $entry = new Application_Model_RightRoles(); + + $entry->setRoleID($row->roleID)->setRightID($row->rightID); + + $entries[] = $entry; + } + + return $entries; + } + + + } -- cgit v1.2.3-55-g7522