summaryrefslogtreecommitdiffstats
path: root/application/models/FilterEntriesMapper.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/models/FilterEntriesMapper.php')
-rw-r--r--application/models/FilterEntriesMapper.php34
1 files changed, 25 insertions, 9 deletions
diff --git a/application/models/FilterEntriesMapper.php b/application/models/FilterEntriesMapper.php
index 54d6e3a..ef2c28f 100644
--- a/application/models/FilterEntriesMapper.php
+++ b/application/models/FilterEntriesMapper.php
@@ -31,20 +31,31 @@ class Application_Model_FilterEntriesMapper
public function save(Application_Model_FilterEntries $filterentries)
{
-
+ try{
$data = array('filterID'=> $filterentries->getFilterID() ,
'filtertypeID'=> $filterentries->getFiltertypeID() ,
'filtervalue'=> $filterentries->getFiltervalue() ,
'filtervalue2'=> $filterentries->getFiltervalue2() );
-
- if (null != ($id1 = $filterentries->getFilterID()) &&
- null != ($id2 = $filterentries->getFiltertypeID()) &&
- $this->getDbTable()->find($filterentries->getFilterID(),$filterentries->getFiltertypeID())) {
+
+ $filterentries2 = new Application_Model_FilterEntries();
+ $result = $this->find($filterentries->getFilterID(),$filterentries->getFiltertypeID(),$filterentries2);
+ echo "<pre style='border:1px solid black;background-color:#F5B800'>";
+ print_r(array($filterentries,$filterentries2,$result));
+ echo "</pre>";
+ $id1 = $filterentries->getFilterID();
+ $id2 = $filterentries->getFiltertypeID();
+ if (0 == count($result) &&
+ null != $id1 &&
+ null != $id2) {
$this->getDbTable()->insert($data);
- echo 'fall1';
+ echo 'inserted';
} else {
- $this->getDbTable()->update($data, array('filterID = ?' => $id1, 'filtertypeID = ?' => $id2));
- echo 'fall2';
+ print_r($this->getDbTable()->update($data, array('filterID = ?' => $id1, 'filtertypeID = ?' => $id2)));
+ echo 'updated';
+ }
+
+ }catch (Zend_Exception $e) {
+ echo "Error message 2: " . $e->getMessage() . "\n";
}
}
@@ -53,13 +64,18 @@ class Application_Model_FilterEntriesMapper
try{
$id1 = $filterentries->getFilterID();
$id2 = $filterentries->getFiltertypeID();
+ echo "<pre>";
+ echo "-----------\n";
var_dump(array($id1,$id2));
+ echo "</pre>";
//TODO: Löschen klappt nicht
- if ((null != $id1) && (null != $id2) &&
+ if ((null == $id1) && (null == $id2) &&
$this->getDbTable()->find($filterentries->getFilterID(),$filterentries->getFiltertypeID())) {
+ echo 'case1';
return;
} else {
$this->getDbTable()->delete(array('filterID = ?' => $id1, 'filtertypeID = ?' => $id2));
+ echo 'case2';
}
}catch (Zend_Exception $e) {