summaryrefslogtreecommitdiffstats
path: root/application/models/PoolEntriesMapper.php
diff options
context:
space:
mode:
authorroot2011-02-09 01:12:05 +0100
committerroot2011-02-09 01:12:05 +0100
commit25ac1a8e603fdaab8dd3851a7c8fd4fb353cc548 (patch)
tree9f99a10e9fede00f2194973a2635c0d99632f320 /application/models/PoolEntriesMapper.php
parentMapperScript & Mapper angelegt (alle die einen Primärschlüssel besitzen) (diff)
downloadpbs2-25ac1a8e603fdaab8dd3851a7c8fd4fb353cc548.tar.gz
pbs2-25ac1a8e603fdaab8dd3851a7c8fd4fb353cc548.tar.xz
pbs2-25ac1a8e603fdaab8dd3851a7c8fd4fb353cc548.zip
Alle Mapper angelegt, Script update
Diffstat (limited to 'application/models/PoolEntriesMapper.php')
-rw-r--r--application/models/PoolEntriesMapper.php67
1 files changed, 67 insertions, 0 deletions
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;
+ }
+
+
+
}