summaryrefslogtreecommitdiffstats
path: root/application/models/BootMapper.php
diff options
context:
space:
mode:
authormichael pereira2011-03-04 03:10:53 +0100
committermichael pereira2011-03-04 03:10:53 +0100
commitcd5f39054796ffe8cdda493d472d302a4de9e768 (patch)
tree517ee81c31809317e36bfd1141dfdb952e021d89 /application/models/BootMapper.php
parentfixing git (diff)
downloadpbs2-cd5f39054796ffe8cdda493d472d302a4de9e768.tar.gz
pbs2-cd5f39054796ffe8cdda493d472d302a4de9e768.tar.xz
pbs2-cd5f39054796ffe8cdda493d472d302a4de9e768.zip
Mapper mit neuer delete function
Diffstat (limited to 'application/models/BootMapper.php')
-rw-r--r--application/models/BootMapper.php83
1 files changed, 83 insertions, 0 deletions
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 @@
+<?php
+
+class Application_Model_BootMapper
+{
+
+ 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_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;
+ }
+
+
+
+}
+