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/BootIsoMapper.php | 67 ++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'application/models/BootIsoMapper.php') diff --git a/application/models/BootIsoMapper.php b/application/models/BootIsoMapper.php index eb4f9c3..97f74a0 100644 --- a/application/models/BootIsoMapper.php +++ b/application/models/BootIsoMapper.php @@ -2,7 +2,74 @@ class Application_Model_BootIsoMapper { + + 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_BootIso $botiso) + { + + $data = array('bootisoID'=> $botiso->getBootisoID() ,'membershipID'=> $botiso->getMembershipID() ,'groupID'=> $botiso->getGroupID() ,'serialnumber'=> $botiso->getSerialnumber() ,'created'=> $botiso->getCreated() ,'expires'=> $botiso->getExpires() ,'public'=> $botiso->getPublic() ); + + if (null === ($id = $botiso->getID()) ) { + unset($data['id']); + $this->getDbTable()->insert($data); + } else { + $this->getDbTable()->update($data, array('id = ?' => $id)); + } + } + + public function find($id, Application_Model_BootIso $botiso) + { + $result = $this->getDbTable()->find($id); + if (0 == count($result)) { + return; + } + + $row = $result->current(); + + $botiso->setBootisoID($row->bootisoID)->setMembershipID($row->membershipID)->setGroupID($row->groupID)->setSerialnumber($row->serialnumber)->setCreated($row->created)->setExpires($row->expires)->setPublic($row->public); + } + + public function fetchAll() + { + $resultSet = $this->getDbTable()->fetchAll(); + $entries = array(); + foreach ($resultSet as $row) { + $entry = new Application_Model_BootIso(); + + $entry->setBootisoID($row->bootisoID)->setMembershipID($row->membershipID)->setGroupID($row->groupID)->setSerialnumber($row->serialnumber)->setCreated($row->created)->setExpires($row->expires)->setPublic($row->public); + + $entries[] = $entry; + } + + return $entries; + } + + + } -- cgit v1.2.3-55-g7522