summaryrefslogtreecommitdiffstats
path: root/application/models
diff options
context:
space:
mode:
Diffstat (limited to 'application/models')
-rwxr-xr-xapplication/models/DbTable/Repeatend.php (renamed from application/models/DbTable/Eventtype.php)4
-rwxr-xr-xapplication/models/DbTable/Repeattype.php20
-rwxr-xr-xapplication/models/DbTable/Runningtype.php20
-rwxr-xr-xapplication/models/Event.php47
-rwxr-xr-xapplication/models/EventMapper.php12
-rwxr-xr-xapplication/models/Repeatend.php (renamed from application/models/Eventtype.php)17
-rwxr-xr-xapplication/models/RepeatendMapper.php (renamed from application/models/EventtypeMapper.php)50
-rwxr-xr-xapplication/models/Repeattype.php110
-rwxr-xr-xapplication/models/RepeattypeMapper.php138
-rwxr-xr-xapplication/models/Runningtype.php111
-rwxr-xr-xapplication/models/RunningtypeMapper.php138
11 files changed, 621 insertions, 46 deletions
diff --git a/application/models/DbTable/Eventtype.php b/application/models/DbTable/Repeatend.php
index 6c54913..d39a481 100755
--- a/application/models/DbTable/Eventtype.php
+++ b/application/models/DbTable/Repeatend.php
@@ -10,10 +10,10 @@
* General information about OpenSLX can be found at http://openslx.org/
*/
-class Application_Model_DbTable_Eventtype extends Zend_Db_Table_Abstract
+class Application_Model_DbTable_Repeatend extends Zend_Db_Table_Abstract
{
- protected $_name = 'poolctrl_eventtype';
+ protected $_name = 'poolctrl_repeatend';
}
diff --git a/application/models/DbTable/Repeattype.php b/application/models/DbTable/Repeattype.php
new file mode 100755
index 0000000..7c3e7b3
--- /dev/null
+++ b/application/models/DbTable/Repeattype.php
@@ -0,0 +1,20 @@
+<?php
+/*
+ * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
+ * This program is free software distributed under the GPL version 2.
+ * See http://gpl.openslx.org/
+ *
+ * If you have any feedback please consult http://feedback.openslx.org/ and
+ * send your suggestions, praise, or complaints to feedback@openslx.org
+ *
+ * General information about OpenSLX can be found at http://openslx.org/
+ */
+
+class Application_Model_DbTable_Repeattype extends Zend_Db_Table_Abstract
+{
+
+ protected $_name = 'poolctrl_repeattype';
+
+
+}
+
diff --git a/application/models/DbTable/Runningtype.php b/application/models/DbTable/Runningtype.php
new file mode 100755
index 0000000..0ed5638
--- /dev/null
+++ b/application/models/DbTable/Runningtype.php
@@ -0,0 +1,20 @@
+<?php
+/*
+ * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
+ * This program is free software distributed under the GPL version 2.
+ * See http://gpl.openslx.org/
+ *
+ * If you have any feedback please consult http://feedback.openslx.org/ and
+ * send your suggestions, praise, or complaints to feedback@openslx.org
+ *
+ * General information about OpenSLX can be found at http://openslx.org/
+ */
+
+class Application_Model_DbTable_Runningtype extends Zend_Db_Table_Abstract
+{
+
+ protected $_name = 'poolctrl_runningtype';
+
+
+}
+
diff --git a/application/models/Event.php b/application/models/Event.php
index 76bb2dc..0b472ea 100755
--- a/application/models/Event.php
+++ b/application/models/Event.php
@@ -25,7 +25,10 @@ class Application_Model_Event
protected $_pbs_bootmenuID;
protected $_pbs_filterID;
protected $_repeat;
- protected $_repeatEnd;
+ protected $_repeattype;
+ protected $_repeatend;
+ protected $_repeatdate;
+ protected $_repeatings;
protected $_immediate;
protected $_running;
protected $_runningtype;
@@ -225,14 +228,48 @@ class Application_Model_Event
return $this;
}
- public function getRepeatEnd()
+ public function getRepeattype()
{
- return $this->_repeatEnd;
+ return $this->_repeattype;
}
- public function setRepeatEnd($_repeatEnd)
+ public function setRepeattype($_repeattype)
{
- $this->_repeatEnd = $_repeatEnd;
+ $this->_repeattype = $__repeattype;
+ return $this;
+ }
+
+
+ public function getRepeatend()
+ {
+ return $this->_repeatend;
+ }
+
+ public function setRepeatend($_repeatend)
+ {
+ $this->_repeatend = $_repeatend;
+ return $this;
+ }
+
+ public function getRepeatdate()
+ {
+ return $this->_repeatdate;
+ }
+
+ public function setRepeatdate($_repeatdate)
+ {
+ $this->_repeatdate = $_repeatdate;
+ return $this;
+ }
+
+ public function getRepeatings()
+ {
+ return $this->_repeatings;
+ }
+
+ public function setRepeatings($_repeatings)
+ {
+ $this->_repeatings = $_repeatings;
return $this;
}
diff --git a/application/models/EventMapper.php b/application/models/EventMapper.php
index 418bab8..864353c 100755
--- a/application/models/EventMapper.php
+++ b/application/models/EventMapper.php
@@ -85,7 +85,7 @@ class Application_Model_EventMapper
public function save(Application_Model_Event $event)
{
- $data = array('eventID'=> $event->getID() ,'category'=> $event->getCategory() ,'title'=> $event->getTitle(), 'pbs_membershipID'=> $event->getPbs_membershipID(),'end'=> $event->getEnd() ,'immediate'=> $event->getImmediate() ,'note'=> $event->getNote() ,'participants'=> $event->getParticipants() ,'pbs_bootosID'=> $event->getPbs_bootosID(),'pbs_poolID'=> $event->getPbs_poolID(),'repeat'=> $event->getRepeat(),'repeatEnd'=> $event->getRepeatEnd(),'start'=> $event->getStart(),'pbs_bootmenuID'=> $event->getPbs_bootmenuID(),'pbs_filterID'=> $event->getPbs_filterID(), 'running' => $event->getRunning(), 'runningtype' => $event->getRunningtype(), 'created' => $event->getCreated() );
+ $data = array('eventID'=> $event->getID() ,'category'=> $event->getCategory() ,'title'=> $event->getTitle(), 'pbs_membershipID'=> $event->getPbs_membershipID(),'end'=> $event->getEnd() ,'immediate'=> $event->getImmediate() ,'note'=> $event->getNote() ,'participants'=> $event->getParticipants() ,'pbs_bootosID'=> $event->getPbs_bootosID(),'pbs_poolID'=> $event->getPbs_poolID(),'repeat'=> $event->getRepeat(),'repeattype'=> $event->getRepeattype(),'repeatend'=> $event->getRepeatend(),'repeatdate'=> $event->getRepeatdate(),'repeatings'=> $event->getRepeatings(),'start'=> $event->getStart(),'pbs_bootmenuID'=> $event->getPbs_bootmenuID(),'pbs_filterID'=> $event->getPbs_filterID(), 'running' => $event->getRunning(), 'runningtype' => $event->getRunningtype(), 'created' => $event->getCreated() );
if (null === ($id = $event->getID()) ) {
unset($data['eventID']);
return $this->getDbTable()->insert($data);
@@ -130,7 +130,10 @@ class Application_Model_EventMapper
->setPbs_filterID($row->pbs_filterID)
->setPbs_bootmenuID($row->pbs_bootmenuID)
->setRepeat($row->repeat)
- ->setRepeatEnd($row->repeatEnd)
+ ->setRepeattype($row->repeattype)
+ ->setRepeatend($row->repeatend)
+ ->setRepeatdate($row->repeatdate)
+ ->setRepeatings($row->repeatings)
->setStart($row->start)
->setRunning($row->running)
->setCreated($row->created)
@@ -159,7 +162,10 @@ class Application_Model_EventMapper
->setPbs_filterID($row->pbs_filterID)
->setPbs_bootmenuID($row->pbs_bootmenuID)
->setRepeat($row->repeat)
- ->setRepeatEnd($row->repeatEnd)
+ ->setRepeattype($row->repeattype)
+ ->setRepeatend($row->repeatend)
+ ->setRepeatdate($row->repeatdate)
+ ->setRepeatings($row->repeatings)
->setStart($row->start)
->setRunning($row->running)
->setCreated($row->created)
diff --git a/application/models/Eventtype.php b/application/models/Repeatend.php
index fe21eeb..cabff52 100755
--- a/application/models/Eventtype.php
+++ b/application/models/Repeatend.php
@@ -10,9 +10,9 @@
* General information about OpenSLX can be found at http://openslx.org/
*/
-class Application_Model_Eventtype
+class Application_Model_Repeatend
{
- protected $_eventtypeID;
+ protected $_repeatendID;
protected $_title;
public function __construct(array $options = null)
@@ -26,7 +26,7 @@ class Application_Model_Eventtype
{
$method = 'set' . $name;
if (('mapper' == $name) || !method_exists($this, $method)) {
- throw new Exception('Invalid eventtype property');
+ throw new Exception('Invalid repeatend property');
}
$this->$method($value);
}
@@ -35,7 +35,7 @@ class Application_Model_Eventtype
{
$method = 'get' . $name;
if (('mapper' == $name) || !method_exists($this, $method)) {
- throw new Exception('Invalid eventtype property');
+ throw new Exception('Invalid repeatend property');
}
return $this->$method();
}
@@ -89,11 +89,11 @@ class Application_Model_Eventtype
public function getID()
{
- return $this->_eventtypeID;
+ return $this->_repeatendID;
}
- public function setID($_eventtypeID)
+ public function setID($_repeatendID)
{
- $this->_eventtypeID = $_eventtypeID;
+ $this->_repeatendID = $_repeatendID;
return $this;
}
@@ -107,5 +107,4 @@ class Application_Model_Eventtype
$this->_title = $_title;
return $this;
}
-}
-
+} \ No newline at end of file
diff --git a/application/models/EventtypeMapper.php b/application/models/RepeatendMapper.php
index 7116975..3af42f2 100755
--- a/application/models/EventtypeMapper.php
+++ b/application/models/RepeatendMapper.php
@@ -1,6 +1,6 @@
<?php
-class Application_Model_EventtypeMapper
+class Application_Model_RepeatendMapper
{
protected $_dbTable;
@@ -33,8 +33,8 @@ class Application_Model_EventtypeMapper
$entries = array();
if(count($result) > 0) {
foreach ($result as $row) {
- $entry = new Application_Model_Eventtype($row);
- $entry->setID($row['eventtypeID']);
+ $entry = new Application_Model_Repeatend($row);
+ $entry->setID($row['repeatendID']);
$entries[] = $entry;
}
}
@@ -66,56 +66,56 @@ class Application_Model_EventtypeMapper
public function getDbTable()
{
if (null === $this->_dbTable) {
- $this->setDbTable('Application_Model_DbTable_Eventtype');
+ $this->setDbTable('Application_Model_DbTable_Repeatend');
}
return $this->_dbTable;
}
- public function save(Application_Model_Eventtype $eventtype)
+ public function save(Application_Model_Repeatend $repeatend)
{
- $data = array('eventtypeID'=> $eventtype->getID() ,'title'=> $eventtype->getTitle() );
+ $data = array('repeatendID'=> $repeatend->getID() ,'title'=> $repeatend->getTitle() );
- if (null === ($id = $eventtype->getID()) ) {
- unset($data['eventtypeID']);
+ if (null === ($id = $repeatend->getID()) ) {
+ unset($data['repeatendID']);
$this->getDbTable()->insert($data);
} else {
- $this->getDbTable()->update($data, array('eventtypeID = ?' => $id));
+ $this->getDbTable()->update($data, array('repeatendID = ?' => $id));
}
}
- public function delete(Application_Model_Eventtype $eventtype)
+ public function delete(Application_Model_Repeatend $repeatend)
{
- if (null === ($id = $eventtype->getID()) ) {
+ if (null === ($id = $repeatend->getID()) ) {
return;
} else {
- $this->getDbTable()->delete(array('eventtypeID = ?' => $id));
+ $this->getDbTable()->delete(array('repeatendID = ?' => $id));
}
}
- public function find($id, Application_Model_Eventtype $eventtype = null)
+ public function find($id, Application_Model_Repeatend $repeatend = null)
{
$result = $this->getDbTable()->find($id);
if (0 == count($result)) {
return;
}
- if($eventtype == null) {
+ if($repeatend == null) {
$return = true;
}
$row = $result->current();
if($return) {
- $eventtype = new Application_Model_Eventtype();
- $eventtype
- ->setID($row->eventtypeID)
+ $repeatend = new Application_Model_Repeatend();
+ $repeatend
+ ->setID($row->repeatendID)
->setTitle($row->title);
- return $eventtype;
+ return $repeatend;
} else {
- $eventtype
- ->setID($row->eventtypeID)
+ $repeatend
+ ->setID($row->repeatendID)
->setTitle($row->title);
}
}
@@ -125,18 +125,14 @@ class Application_Model_EventtypeMapper
$resultSet = $this->getDbTable()->fetchAll();
$entries = array();
foreach ($resultSet as $row) {
- $entry = new Application_Model_Eventtype();
+ $entry = new Application_Model_Repeatend();
$entry
- ->setID($row->eventtypeID)
+ ->setID($row->repeatendID)
->setTitle($row->title);
$entries[] = $entry;
}
return $entries;
}
-
-
-
-}
-
+} \ No newline at end of file
diff --git a/application/models/Repeattype.php b/application/models/Repeattype.php
new file mode 100755
index 0000000..43ad949
--- /dev/null
+++ b/application/models/Repeattype.php
@@ -0,0 +1,110 @@
+<?php
+/*
+ * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
+ * This program is free software distributed under the GPL version 2.
+ * See http://gpl.openslx.org/
+ *
+ * If you have any feedback please consult http://feedback.openslx.org/ and
+ * send your suggestions, praise, or complaints to feedback@openslx.org
+ *
+ * General information about OpenSLX can be found at http://openslx.org/
+ */
+
+class Application_Model_Repeattype
+{
+ protected $_repeattypeID;
+ protected $_title;
+
+ public function __construct(array $options = null)
+ {
+ if (is_array($options)) {
+ $this->setOptions($options);
+ }
+ }
+
+ public function __set($name, $value)
+ {
+ $method = 'set' . $name;
+ if (('mapper' == $name) || !method_exists($this, $method)) {
+ throw new Exception('Invalid repeattype property');
+ }
+ $this->$method($value);
+ }
+
+ public function __get($name)
+ {
+ $method = 'get' . $name;
+ if (('mapper' == $name) || !method_exists($this, $method)) {
+ throw new Exception('Invalid repeattype property');
+ }
+ return $this->$method();
+ }
+
+ public function setOptions(array $options)
+ {
+ $methods = get_class_methods($this);
+ foreach ($options as $key => $value) {
+ $method = 'set' . ucfirst($key);
+ if (in_array($method, $methods)) {
+ $this->$method($value);
+ }
+ }
+ return $this;
+ }
+
+ /**
+ * Returns current data as associative array using ReflectionClass
+ *
+ * @return array Returns associative array containing model data
+ * If "get"-method not available (our primary keys) the function getID() is called
+ */
+ public function toArray()
+ {
+ $reflectionClass = new ReflectionClass($this);
+ $properties = $reflectionClass->getProperties();
+ $result = array();
+ foreach ($properties as $property) {
+ $key = $property->name;
+ if (substr($key, 0, 1) != '_' && $this->$key !== null) {
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ } else {
+ $result[$key] = $this->$key;
+ }
+ }
+ elseif(substr($key, 0, 1) == '_' && $this->$key !== null) {
+ $key = substr($key, 1);
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ }else{
+ $result[$key] = $this->getID();
+ }
+
+ }
+ }
+ return $result;
+ }
+
+ public function getID()
+ {
+ return $this->_repeattypeID;
+ }
+ public function setID($_repeattypeID)
+ {
+ $this->_repeattypeID = $_repeattypeID;
+ return $this;
+ }
+
+ public function getTitle()
+ {
+ return $this->_title;
+ }
+
+ public function setTitle($_title)
+ {
+ $this->_title = $_title;
+ return $this;
+ }
+} \ No newline at end of file
diff --git a/application/models/RepeattypeMapper.php b/application/models/RepeattypeMapper.php
new file mode 100755
index 0000000..015c4e2
--- /dev/null
+++ b/application/models/RepeattypeMapper.php
@@ -0,0 +1,138 @@
+<?php
+
+class Application_Model_RepeattypeMapper
+{
+ protected $_dbTable;
+
+ public function findBy($where, $array=false, $order=false)
+ {
+ foreach($where as $k => $v){
+ if($v != null)
+ $where2[] = "$k = '$v'";
+ else
+ $where2[] = "$k IS NULL";
+ }
+ $where = implode(" AND " ,$where2);
+
+ try{
+ $db = Zend_Db_Table::getDefaultAdapter();
+ $select = $this->getDbTable()->select()
+ ->from($this->_dbTable)
+ ->where($where);
+
+ if(is_array($order)){
+ foreach ($order as $k => $v)
+ $a[] = "$k $v";
+ $select->order($a);
+ }
+
+ $stmt = $select->query();
+ $result = $stmt->fetchAll();
+
+ if(!$array){
+ $entries = array();
+ if(count($result) > 0) {
+ foreach ($result as $row) {
+ $entry = new Application_Model_Repeattype($row);
+ $entry->setID($row['repeattypeID']);
+ $entries[] = $entry;
+ }
+ }
+ return $entries;
+ }else{
+ return $result;
+ }
+
+ }catch (Zend_Exception $e) {
+ echo "Error message 2: " . $e->getMessage() . "\n";
+ }
+ }
+
+ 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_Repeattype');
+ }
+
+ return $this->_dbTable;
+ }
+
+ public function save(Application_Model_Repeattype $repeattype)
+ {
+
+ $data = array('repeattypeID'=> $repeattype->getID() ,'title'=> $repeattype->getTitle() );
+
+ if (null === ($id = $repeattype->getID()) ) {
+ unset($data['repeattypeID']);
+ $this->getDbTable()->insert($data);
+ } else {
+ $this->getDbTable()->update($data, array('repeattypeID = ?' => $id));
+ }
+ }
+
+ public function delete(Application_Model_Repeattype $repeattype)
+ {
+ if (null === ($id = $repeattype->getID()) ) {
+ return;
+ } else {
+ $this->getDbTable()->delete(array('repeattypeID = ?' => $id));
+ }
+ }
+
+ public function find($id, Application_Model_Repeattype $repeattype = null)
+ {
+ $result = $this->getDbTable()->find($id);
+ if (0 == count($result)) {
+ return;
+ }
+
+ if($repeattype == null) {
+ $return = true;
+ }
+
+ $row = $result->current();
+
+ if($return) {
+ $repeattype = new Application_Model_Repeattype();
+ $repeattype
+ ->setID($row->repeattypeID)
+ ->setTitle($row->title);
+ return $repeattype;
+ } else {
+ $repeattype
+ ->setID($row->repeattypeID)
+ ->setTitle($row->title);
+ }
+ }
+
+ public function fetchAll()
+ {
+ $resultSet = $this->getDbTable()->fetchAll();
+ $entries = array();
+ foreach ($resultSet as $row) {
+ $entry = new Application_Model_Repeattype();
+
+ $entry
+ ->setID($row->repeattypeID)
+ ->setTitle($row->title);
+
+ $entries[] = $entry;
+ }
+ return $entries;
+ }
+} \ No newline at end of file
diff --git a/application/models/Runningtype.php b/application/models/Runningtype.php
new file mode 100755
index 0000000..d08222d
--- /dev/null
+++ b/application/models/Runningtype.php
@@ -0,0 +1,111 @@
+<?php
+/*
+ * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
+ * This program is free software distributed under the GPL version 2.
+ * See http://gpl.openslx.org/
+ *
+ * If you have any feedback please consult http://feedback.openslx.org/ and
+ * send your suggestions, praise, or complaints to feedback@openslx.org
+ *
+ * General information about OpenSLX can be found at http://openslx.org/
+ */
+
+class Application_Model_Runningtype
+{
+ protected $_runningtypeID;
+ protected $_title;
+
+ public function __construct(array $options = null)
+ {
+ if (is_array($options)) {
+ $this->setOptions($options);
+ }
+ }
+
+ public function __set($name, $value)
+ {
+ $method = 'set' . $name;
+ if (('mapper' == $name) || !method_exists($this, $method)) {
+ throw new Exception('Invalid runningtype property');
+ }
+ $this->$method($value);
+ }
+
+ public function __get($name)
+ {
+ $method = 'get' . $name;
+ if (('mapper' == $name) || !method_exists($this, $method)) {
+ throw new Exception('Invalid runningtype property');
+ }
+ return $this->$method();
+ }
+
+ public function setOptions(array $options)
+ {
+ $methods = get_class_methods($this);
+ foreach ($options as $key => $value) {
+ $method = 'set' . ucfirst($key);
+ if (in_array($method, $methods)) {
+ $this->$method($value);
+ }
+ }
+ return $this;
+ }
+
+ /**
+ * Returns current data as associative array using ReflectionClass
+ *
+ * @return array Returns associative array containing model data
+ * If "get"-method not available (our primary keys) the function getID() is called
+ */
+ public function toArray()
+ {
+ $reflectionClass = new ReflectionClass($this);
+ $properties = $reflectionClass->getProperties();
+ $result = array();
+ foreach ($properties as $property) {
+ $key = $property->name;
+ if (substr($key, 0, 1) != '_' && $this->$key !== null) {
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ } else {
+ $result[$key] = $this->$key;
+ }
+ }
+ elseif(substr($key, 0, 1) == '_' && $this->$key !== null) {
+ $key = substr($key, 1);
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ }else{
+ $result[$key] = $this->getID();
+ }
+
+ }
+ }
+ return $result;
+ }
+
+ public function getID()
+ {
+ return $this->_runningtypeID;
+ }
+ public function setID($_runningtypeID)
+ {
+ $this->_runningtypeID = $_runningtypeID;
+ return $this;
+ }
+
+ public function getTitle()
+ {
+ return $this->_title;
+ }
+
+ public function setTitle($_title)
+ {
+ $this->_title = $_title;
+ return $this;
+ }
+}
+
diff --git a/application/models/RunningtypeMapper.php b/application/models/RunningtypeMapper.php
new file mode 100755
index 0000000..621405a
--- /dev/null
+++ b/application/models/RunningtypeMapper.php
@@ -0,0 +1,138 @@
+<?php
+
+class Application_Model_RunningtypeMapper
+{
+ protected $_dbTable;
+
+ public function findBy($where, $array=false, $order=false)
+ {
+ foreach($where as $k => $v){
+ if($v != null)
+ $where2[] = "$k = '$v'";
+ else
+ $where2[] = "$k IS NULL";
+ }
+ $where = implode(" AND " ,$where2);
+
+ try{
+ $db = Zend_Db_Table::getDefaultAdapter();
+ $select = $this->getDbTable()->select()
+ ->from($this->_dbTable)
+ ->where($where);
+
+ if(is_array($order)){
+ foreach ($order as $k => $v)
+ $a[] = "$k $v";
+ $select->order($a);
+ }
+
+ $stmt = $select->query();
+ $result = $stmt->fetchAll();
+
+ if(!$array){
+ $entries = array();
+ if(count($result) > 0) {
+ foreach ($result as $row) {
+ $entry = new Application_Model_Runningtype($row);
+ $entry->setID($row['runningtypeID']);
+ $entries[] = $entry;
+ }
+ }
+ return $entries;
+ }else{
+ return $result;
+ }
+
+ }catch (Zend_Exception $e) {
+ echo "Error message 2: " . $e->getMessage() . "\n";
+ }
+ }
+
+ 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_Runningtype');
+ }
+
+ return $this->_dbTable;
+ }
+
+ public function save(Application_Model_Runningtype $runningtype)
+ {
+
+ $data = array('runningtypeID'=> $runningtype->getID() ,'title'=> $runningtype->getTitle() );
+
+ if (null === ($id = $runningtype->getID()) ) {
+ unset($data['runningtypeID']);
+ $this->getDbTable()->insert($data);
+ } else {
+ $this->getDbTable()->update($data, array('runningtypeID = ?' => $id));
+ }
+ }
+
+ public function delete(Application_Model_Runningtype $runningtype)
+ {
+ if (null === ($id = $runningtype->getID()) ) {
+ return;
+ } else {
+ $this->getDbTable()->delete(array('runningtypeID = ?' => $id));
+ }
+ }
+
+ public function find($id, Application_Model_Runningtype $runningtype = null)
+ {
+ $result = $this->getDbTable()->find($id);
+ if (0 == count($result)) {
+ return;
+ }
+
+ if($runningtype == null) {
+ $return = true;
+ }
+
+ $row = $result->current();
+
+ if($return) {
+ $runningtype = new Application_Model_Runningtype();
+ $runningtype
+ ->setID($row->runningtypeID)
+ ->setTitle($row->title);
+ return $runningtype;
+ } else {
+ $runningtype
+ ->setID($row->runningtypeID)
+ ->setTitle($row->title);
+ }
+ }
+
+ public function fetchAll()
+ {
+ $resultSet = $this->getDbTable()->fetchAll();
+ $entries = array();
+ foreach ($resultSet as $row) {
+ $entry = new Application_Model_Runningtype();
+
+ $entry
+ ->setID($row->runningtypeID)
+ ->setTitle($row->title);
+
+ $entries[] = $entry;
+ }
+ return $entries;
+ }
+} \ No newline at end of file