diff options
| author | mentos | 2011-01-31 10:20:48 +0100 |
|---|---|---|
| committer | mentos | 2011-01-31 10:20:48 +0100 |
| commit | c2480358cf792cc2abd434e471a85ffba55318af (patch) | |
| tree | 3e6eff9dd9d7e2c3bb420beadff2cfba48be032d /application/models/BootMenuEntriesMapper.php | |
| parent | setter/getter geƤndert damit es Konvention setGrossbuchstabe() entspricht (diff) | |
| download | pbs2-c2480358cf792cc2abd434e471a85ffba55318af.tar.gz pbs2-c2480358cf792cc2abd434e471a85ffba55318af.tar.xz pbs2-c2480358cf792cc2abd434e471a85ffba55318af.zip | |
some fixes
Diffstat (limited to 'application/models/BootMenuEntriesMapper.php')
| -rw-r--r-- | application/models/BootMenuEntriesMapper.php | 77 |
1 files changed, 76 insertions, 1 deletions
diff --git a/application/models/BootMenuEntriesMapper.php b/application/models/BootMenuEntriesMapper.php index ed13180..576e799 100644 --- a/application/models/BootMenuEntriesMapper.php +++ b/application/models/BootMenuEntriesMapper.php @@ -1,8 +1,83 @@ <?php -class Application_Model_BootMenuEntriesMapper +class Application_Model_BootEntriesMapper { + 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_TABLENAME'); + } + + return $this->_dbTable; + } + + public function save(Application_Model_TABLENAME $tablenamevar) + { + + $data = array( + 'bootosID' => $tablenamevar->getBootosID(), + 'bootmenuID' => $tablenamevar->getMenuID(), + 'title' => $tablenamevar->getTitle(), + 'kcl' => $tablenamevar->getKcl(), + 'order' => $tablenamevar->getOrder() + ); + + if (null === ($id = $tablenamevar->getId()) ) { + unset($data['id']); + $this->getDbTable()->insert($data); + } else { + $this->getDbTable()->update($data, array('id = ?' => $id)); + } + } + + public function find($id, Application_Model_TABLENAME $tablenamevar) + { + $result = $this->getDbTable()->find($id); + if (0 == count($result)) { + return; + } + + $row = $result->current(); + + $tablenamevar->setId($row->id) + ->setEmail($row->email) + ->setComment($row->comment) + ->setCreated($row->created); + } + + public function fetchAll() + { + $resultSet = $this->getDbTable()->fetchAll(); + $entries = array(); + foreach ($resultSet as $row) { + $entry = new Application_Model_TABLENAME(); + + $entry->setId($row->id) + ->setEmail($row->email) + ->setComment($row->comment) + ->setCreated($row->created); + + $entries[] = $entry; + } + + return $entries; + } } |
