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/PoolEntriesMapper.php | 67 ++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'application/models/PoolEntriesMapper.php') diff --git a/application/models/PoolEntriesMapper.php b/application/models/PoolEntriesMapper.php index 6438881..4929a36 100644 --- a/application/models/PoolEntriesMapper.php +++ b/application/models/PoolEntriesMapper.php @@ -2,7 +2,74 @@ class Application_Model_PoolEntriesMapper { + + 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_PoolEntries $polentries) + { + + $data = array('poolID'=> $polentries->getPoolID() ,'clientID'=> $polentries->getClientID() ); + + if (null === ($id = $polentries->getID()) ) { + unset($data['id']); + $this->getDbTable()->insert($data); + } else { + $this->getDbTable()->update($data, array('id = ?' => $id)); + } + } + + public function find($id, Application_Model_PoolEntries $polentries) + { + $result = $this->getDbTable()->find($id); + if (0 == count($result)) { + return; + } + + $row = $result->current(); + + $polentries->setPoolID($row->poolID)->setClientID($row->clientID); + } + + public function fetchAll() + { + $resultSet = $this->getDbTable()->fetchAll(); + $entries = array(); + foreach ($resultSet as $row) { + $entry = new Application_Model_PoolEntries(); + + $entry->setPoolID($row->poolID)->setClientID($row->clientID); + + $entries[] = $entry; + } + + return $entries; + } + + + } -- cgit v1.2.3-55-g7522