From cd5f39054796ffe8cdda493d472d302a4de9e768 Mon Sep 17 00:00:00 2001 From: michael pereira Date: Fri, 4 Mar 2011 03:10:53 +0100 Subject: Mapper mit neuer delete function --- application/models/BootMapper.php | 83 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 application/models/BootMapper.php (limited to 'application/models/BootMapper.php') diff --git a/application/models/BootMapper.php b/application/models/BootMapper.php new file mode 100644 index 0000000..43f9d3d --- /dev/null +++ b/application/models/BootMapper.php @@ -0,0 +1,83 @@ +_dbTable = $dbTable; + + return $this; + } + + public function getDbTable() + { + if (null === $this->_dbTable) { + $this->setDbTable('Application_Model_DbTable_Boot'); + } + + return $this->_dbTable; + } + + public function save(Application_Model_Boot $bot) + { + + $data = array(); + + if (null === ($id = $bot->getID()) ) { + unset($data['botID']); + $this->getDbTable()->insert($data); + } else { + $this->getDbTable()->update($data, array('botID = ?' => $id)); + } + } + + public function delete(Application_Model_Boot $bot) + { + if (null === ($id = $bot->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('botID = ?' => $id)); + } + } + + public function find($id, Application_Model_Boot $bot) + { + $result = $this->getDbTable()->find($id); + if (0 == count($result)) { + return; + } + + $row = $result->current(); + + $bot; + } + + public function fetchAll() + { + $resultSet = $this->getDbTable()->fetchAll(); + $entries = array(); + foreach ($resultSet as $row) { + $entry = new Application_Model_Boot(); + + $entry; + + $entries[] = $entry; + } + return $entries; + } + + + +} + -- cgit v1.2.3-55-g7522