summaryrefslogtreecommitdiffstats
path: root/application/models/BootIsoMapper.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/models/BootIsoMapper.php')
-rw-r--r--application/models/BootIsoMapper.php67
1 files changed, 67 insertions, 0 deletions
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;
+ }
+
+
+
}