summaryrefslogtreecommitdiffstats
path: root/application/models
diff options
context:
space:
mode:
authormichael pereira2011-04-04 17:12:48 +0200
committermichael pereira2011-04-04 17:12:48 +0200
commit8ceb7bad18f257127ad5790a9c0ec157d7e03f4d (patch)
treea83b3d35741914087db7eb8c169c1f5c3b0bd02a /application/models
parentgetRessoources bei Play werden angezeigt (diff)
downloadpbs2-8ceb7bad18f257127ad5790a9c0ec157d7e03f4d.tar.gz
pbs2-8ceb7bad18f257127ad5790a9c0ec157d7e03f4d.tar.xz
pbs2-8ceb7bad18f257127ad5790a9c0ec157d7e03f4d.zip
WICHTIG findBy Methode geändert & alles angepasst, siehe Ticket
Diffstat (limited to 'application/models')
-rw-r--r--application/models/BootIsoMapper.php19
-rw-r--r--application/models/BootMenuEntriesMapper.php52
-rw-r--r--application/models/BootMenuMapper.php19
-rw-r--r--application/models/BootOsMapper.php19
-rw-r--r--application/models/ClientMapper.php33
-rw-r--r--application/models/ConfigMapper.php20
-rw-r--r--application/models/FilterEntriesMapper.php33
-rw-r--r--application/models/FilterMapper.php34
-rw-r--r--application/models/FilterTypeMapper.php34
-rw-r--r--application/models/GroupGroupsMapper.php46
-rw-r--r--application/models/GroupMapper.php26
-rw-r--r--application/models/GroupRequestMapper.php33
-rw-r--r--application/models/MembershipMapper.php35
-rw-r--r--application/models/PasswordRecoveryMapper.php46
-rw-r--r--application/models/PersonMapper.php33
-rw-r--r--application/models/PoolEntriesMapper.php33
-rw-r--r--application/models/PoolMapper.php33
-rw-r--r--application/models/PreBootMapper.php37
-rw-r--r--application/models/RightCategoryMapper.php47
-rw-r--r--application/models/RightMapper.php33
-rw-r--r--application/models/RightRolesMapper.php46
-rw-r--r--application/models/RoleMapper.php33
-rw-r--r--application/models/SessionMapper.php33
23 files changed, 648 insertions, 129 deletions
diff --git a/application/models/BootIsoMapper.php b/application/models/BootIsoMapper.php
index c8c4b41..5b3f748 100644
--- a/application/models/BootIsoMapper.php
+++ b/application/models/BootIsoMapper.php
@@ -5,13 +5,26 @@ class Application_Model_BootIsoMapper
protected $_dbTable;
- public function findBy($criteria, $value, $array=false)
+ 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($criteria . ' = ?', $value);
+ ->where($where);
+ if(is_array($order)){
+ foreach ($order as $k => $v)
+ $a[] = "$k $v";
+ $select->order($a);
+ }
$stmt = $select->query();
$result = $stmt->fetchAll();
@@ -26,7 +39,7 @@ class Application_Model_BootIsoMapper
}else{
return $result;
}
-
+
}catch (Zend_Exception $e) {
echo "Error message 2: " . $e->getMessage() . "\n";
}
diff --git a/application/models/BootMenuEntriesMapper.php b/application/models/BootMenuEntriesMapper.php
index 937d81b..4d82c96 100644
--- a/application/models/BootMenuEntriesMapper.php
+++ b/application/models/BootMenuEntriesMapper.php
@@ -5,44 +5,42 @@ class Application_Model_BootMenuEntriesMapper
protected $_dbTable;
- public function findBy($criteria, $value)
+ public function findBy($where, $array=false, $order=false)
{
+
+ foreach($where as $k => $v){
+ $where[] = "$k = '$v'";
+ }
+ $where = implode(" AND " ,$where);
+
try{
$db = Zend_Db_Table::getDefaultAdapter();
+
$select = $this->getDbTable()->select()
->from($this->_dbTable)
- ->where($criteria . ' = ?', $value)
- ->order('order');
- $stmt = $select->query();
- $resultSet = $stmt->fetchAll();
-
- $entries = array();
- foreach ($resultSet as $row) {
+ ->where($where)
+ ->order('order');
- $entry = new Application_Model_BootMenuEntries($row);
- $entry->setID($row['bootmenuentriesID']);
- $entries[] = $entry;
+ if(is_array($order)){
+ foreach ($order as $k => $v)
+ $a[] = "$k $v";
+ $select->order($a);
}
- return $entries;
-
- }catch (Zend_Exception $e) {
- echo "Error message 2: " . $e->getMessage() . "\n";
- }
- }
-
- public function findByArray($criteria, $value)
- {
- try{
- $db = Zend_Db_Table::getDefaultAdapter();
- $select = $this->getDbTable()->select()
- ->from($this->_dbTable)
- ->where($criteria . ' = ?', $value)
- ->order('order');
$stmt = $select->query();
$result = $stmt->fetchAll();
- return $result;
+ if(!$array){
+ $entries = array();
+ foreach ($result as $row) {
+ $entry = new Application_Model_BootMenuEntries($row);
+ $entry->setID($row['bootmenuentriesID']);
+ $entries[] = $entry;
+ }
+ return $entries;
+ }else{
+ return $result;
+ }
}catch (Zend_Exception $e) {
echo "Error message 2: " . $e->getMessage() . "\n";
diff --git a/application/models/BootMenuMapper.php b/application/models/BootMenuMapper.php
index c8065ec..60c506d 100644
--- a/application/models/BootMenuMapper.php
+++ b/application/models/BootMenuMapper.php
@@ -5,13 +5,28 @@ class Application_Model_BootMenuMapper
protected $_dbTable;
- public function findBy($criteria, $value, $array=false)
+ 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($criteria . ' = ?', $value);
+ ->where($where);
+
+ if(is_array($order)){
+ foreach ($order as $k => $v)
+ $a[] = "$k $v";
+ $select->order($a);
+ }
+
$stmt = $select->query();
$result = $stmt->fetchAll();
diff --git a/application/models/BootOsMapper.php b/application/models/BootOsMapper.php
index 3ac2a8c..7a4be44 100644
--- a/application/models/BootOsMapper.php
+++ b/application/models/BootOsMapper.php
@@ -5,13 +5,28 @@ class Application_Model_BootOsMapper
protected $_dbTable;
- public function findBy($criteria, $value, $array=false)
+ 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($criteria . ' = ?', $value);
+ ->where($where);
+
+ if(is_array($order)){
+ foreach ($order as $k => $v)
+ $a[] = "$k $v";
+ $select->order($a);
+ }
+
$stmt = $select->query();
$result = $stmt->fetchAll();
diff --git a/application/models/ClientMapper.php b/application/models/ClientMapper.php
index 2c23cfc..a86f4b0 100644
--- a/application/models/ClientMapper.php
+++ b/application/models/ClientMapper.php
@@ -5,16 +5,43 @@ class Application_Model_ClientMapper
protected $_dbTable;
- public function findBy($criteria, $value)
+ 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($criteria . ' = ?', $value);
+ ->where($where);
+
+ if(is_array($order)){
+ foreach ($order as $k => $v)
+ $a[] = "$k $v";
+ $select->order($a);
+ }
+
$stmt = $select->query();
$result = $stmt->fetchAll();
- return $result;
+
+ if(!$array){
+ $entries = array();
+ foreach ($result as $row) {
+ $entry = new Application_Model_Client($row);
+ $entry->setID($row['clientID']);
+ $entries[] = $entry;
+ }
+ return $entries;
+ }else{
+ return $result;
+ }
+
}catch (Zend_Exception $e) {
echo "Error message 2: " . $e->getMessage() . "\n";
}
diff --git a/application/models/ConfigMapper.php b/application/models/ConfigMapper.php
index fd6760c..dbcb0e5 100644
--- a/application/models/ConfigMapper.php
+++ b/application/models/ConfigMapper.php
@@ -5,13 +5,28 @@ class Application_Model_ConfigMapper
protected $_dbTable;
- public function findBy($criteria, $value, $array=false)
+ 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($criteria . ' = ?', $value);
+ ->where($where);
+
+ if(is_array($order)){
+ foreach ($order as $k => $v)
+ $a[] = "$k $v";
+ $select->order($a);
+ }
+
$stmt = $select->query();
$result = $stmt->fetchAll();
@@ -31,7 +46,6 @@ class Application_Model_ConfigMapper
echo "Error message 2: " . $e->getMessage() . "\n";
}
}
-
public function setDbTable($dbTable)
{
if (is_string($dbTable)) {
diff --git a/application/models/FilterEntriesMapper.php b/application/models/FilterEntriesMapper.php
index 11236af..e667997 100644
--- a/application/models/FilterEntriesMapper.php
+++ b/application/models/FilterEntriesMapper.php
@@ -5,16 +5,43 @@ class Application_Model_FilterEntriesMapper
protected $_dbTable;
- public function findBy($criteria, $value)
+ 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($criteria . ' = ?', $value);
+ ->where($where);
+
+ if(is_array($order)){
+ foreach ($order as $k => $v)
+ $a[] = "$k $v";
+ $select->order($a);
+ }
+
$stmt = $select->query();
$result = $stmt->fetchAll();
- return $result;
+
+ if(!$array){
+ $entries = array();
+ foreach ($result as $row) {
+ $entry = new Application_Model_FilterEntries($row);
+ $entry->setID($row['filterentriesID']);
+ $entries[] = $entry;
+ }
+ return $entries;
+ }else{
+ return $result;
+ }
+
}catch (Zend_Exception $e) {
echo "Error message 2: " . $e->getMessage() . "\n";
}
diff --git a/application/models/FilterMapper.php b/application/models/FilterMapper.php
index d4b8d54..4173cbf 100644
--- a/application/models/FilterMapper.php
+++ b/application/models/FilterMapper.php
@@ -5,19 +5,43 @@ class Application_Model_FilterMapper
protected $_dbTable;
- public function findBy($criteria, $value, $order='',$sort='')
+ 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($criteria . ' = ?', $value);
- if($order != '' && $sort != ''){
- $select->order(array("$order $sort"));
+ ->where($where);
+
+ if(is_array($order)){
+ foreach ($order as $k => $v)
+ $a[] = "$k $v";
+ $select->order($a);
}
+
$stmt = $select->query();
$result = $stmt->fetchAll();
- return $result;
+
+ if(!$array){
+ $entries = array();
+ foreach ($result as $row) {
+ $entry = new Application_Model_Filter($row);
+ $entry->setID($row['filterID']);
+ $entries[] = $entry;
+ }
+ return $entries;
+ }else{
+ return $result;
+ }
+
}catch (Zend_Exception $e) {
echo "Error message 2: " . $e->getMessage() . "\n";
}
diff --git a/application/models/FilterTypeMapper.php b/application/models/FilterTypeMapper.php
index 45675d8..cd334ba 100644
--- a/application/models/FilterTypeMapper.php
+++ b/application/models/FilterTypeMapper.php
@@ -5,21 +5,47 @@ class Application_Model_FilterTypeMapper
protected $_dbTable;
- public function findBy($criteria, $value)
+ 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($criteria . ' = ?', $value);
+ ->where($where);
+
+ if(is_array($order)){
+ foreach ($order as $k => $v)
+ $a[] = "$k $v";
+ $select->order($a);
+ }
+
$stmt = $select->query();
$result = $stmt->fetchAll();
- return $result;
+
+ if(!$array){
+ $entries = array();
+ foreach ($result as $row) {
+ $entry = new Application_Model_FilterType($row);
+ $entry->setID($row['filtertypeID']);
+ $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)) {
diff --git a/application/models/GroupGroupsMapper.php b/application/models/GroupGroupsMapper.php
index f19ff02..a1329fe 100644
--- a/application/models/GroupGroupsMapper.php
+++ b/application/models/GroupGroupsMapper.php
@@ -5,20 +5,46 @@ class Application_Model_GroupGroupsMapper
protected $_dbTable;
- public function findBy($criteria, $value)
- {
- try{
+ 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($criteria . ' = ?', $value);
+ $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();
- return $result;
- }catch (Zend_Exception $e) {
- echo "Error message 2: " . $e->getMessage() . "\n";
+
+ if(!$array){
+ $entries = array();
+ foreach ($result as $row) {
+ $entry = new Application_Model_GroupGroups($row);
+ $entries[] = $entry;
+ }
+ return $entries;
+ }else{
+ return $result;
+ }
+
+ }catch (Zend_Exception $e) {
+ echo "Error message 2: " . $e->getMessage() . "\n";
}
- }
+ }
public function setDbTable($dbTable)
{
diff --git a/application/models/GroupMapper.php b/application/models/GroupMapper.php
index fa458d1..f9c3819 100644
--- a/application/models/GroupMapper.php
+++ b/application/models/GroupMapper.php
@@ -5,16 +5,36 @@ class Application_Model_GroupMapper
protected $_dbTable;
- public function findBy($criteria, $value)
+ public function findBy($where, $array=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($criteria . ' = ?', $value);
+ ->where($where);
$stmt = $select->query();
$result = $stmt->fetchAll();
- return $result;
+
+ if(!$array){
+ $entries = array();
+ foreach ($result as $row) {
+ $entry = new Application_Model_Group($row);
+ $entry->setID($row['groupID']);
+ $entries[] = $entry;
+ }
+ return $entries;
+ }else{
+ return $result;
+ }
+
}catch (Zend_Exception $e) {
echo "Error message 2: " . $e->getMessage() . "\n";
}
diff --git a/application/models/GroupRequestMapper.php b/application/models/GroupRequestMapper.php
index dff8703..cac51cd 100644
--- a/application/models/GroupRequestMapper.php
+++ b/application/models/GroupRequestMapper.php
@@ -5,16 +5,43 @@ class Application_Model_GroupRequestMapper
protected $_dbTable;
- public function findBy($criteria, $value)
+ 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($criteria . ' = ?', $value);
+ ->where($where);
+
+ if(is_array($order)){
+ foreach ($order as $k => $v)
+ $a[] = "$k $v";
+ $select->order($a);
+ }
+
$stmt = $select->query();
$result = $stmt->fetchAll();
- return $result;
+
+ if(!$array){
+ $entries = array();
+ foreach ($result as $row) {
+ $entry = new Application_Model_GroupRequest($row);
+ $entry->setID($row['grouprequestID']);
+ $entries[] = $entry;
+ }
+ return $entries;
+ }else{
+ return $result;
+ }
+
}catch (Zend_Exception $e) {
echo "Error message 2: " . $e->getMessage() . "\n";
}
diff --git a/application/models/MembershipMapper.php b/application/models/MembershipMapper.php
index 5aa0bfd..67b4985 100644
--- a/application/models/MembershipMapper.php
+++ b/application/models/MembershipMapper.php
@@ -4,17 +4,44 @@ class Application_Model_MembershipMapper
{
protected $_dbTable;
-
- public function findBy($criteria, $value)
+
+ 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($criteria . ' = ?', $value);
+ ->where($where);
+
+ if(is_array($order)){
+ foreach ($order as $k => $v)
+ $a[] = "$k $v";
+ $select->order($a);
+ }
+
$stmt = $select->query();
$result = $stmt->fetchAll();
- return $result;
+
+ if(!$array){
+ $entries = array();
+ foreach ($result as $row) {
+ $entry = new Application_Model_Membership($row);
+ $entry->setID($row['membershipID']);
+ $entries[] = $entry;
+ }
+ return $entries;
+ }else{
+ return $result;
+ }
+
}catch (Zend_Exception $e) {
echo "Error message 2: " . $e->getMessage() . "\n";
}
diff --git a/application/models/PasswordRecoveryMapper.php b/application/models/PasswordRecoveryMapper.php
index 97f5a5a..0bd6eb1 100644
--- a/application/models/PasswordRecoveryMapper.php
+++ b/application/models/PasswordRecoveryMapper.php
@@ -4,20 +4,46 @@ class Application_Model_PasswordRecoveryMapper
{
protected $_dbTable;
- public function findBy($criteria, $value)
- {
- try{
+ 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($criteria . ' = ?', $value);
+ $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();
- return $result;
- }catch (Zend_Exception $e) {
- echo "Error message 2: " . $e->getMessage() . "\n";
+
+ if(!$array){
+ $entries = array();
+ foreach ($result as $row) {
+ $entry = new Application_Model_PasswordRecovery($row);
+ $entries[] = $entry;
+ }
+ return $entries;
+ }else{
+ return $result;
+ }
+
+ }catch (Zend_Exception $e) {
+ echo "Error message 2: " . $e->getMessage() . "\n";
}
- }
+ }
public function setDbTable($dbTable)
{
diff --git a/application/models/PersonMapper.php b/application/models/PersonMapper.php
index de05c0c..537d862 100644
--- a/application/models/PersonMapper.php
+++ b/application/models/PersonMapper.php
@@ -5,16 +5,43 @@ class Application_Model_PersonMapper
protected $_dbTable;
- public function findBy($criteria, $value)
+ 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($criteria . ' = ?', $value);
+ ->where($where);
+
+ if(is_array($order)){
+ foreach ($order as $k => $v)
+ $a[] = "$k $v";
+ $select->order($a);
+ }
+
$stmt = $select->query();
$result = $stmt->fetchAll();
- return $result;
+
+ if(!$array){
+ $entries = array();
+ foreach ($result as $row) {
+ $entry = new Application_Model_Person($row);
+ $entry->setID($row['personID']);
+ $entries[] = $entry;
+ }
+ return $entries;
+ }else{
+ return $result;
+ }
+
}catch (Zend_Exception $e) {
echo "Error message 2: " . $e->getMessage() . "\n";
}
diff --git a/application/models/PoolEntriesMapper.php b/application/models/PoolEntriesMapper.php
index 8574c01..fd16cc1 100644
--- a/application/models/PoolEntriesMapper.php
+++ b/application/models/PoolEntriesMapper.php
@@ -5,16 +5,43 @@ class Application_Model_PoolEntriesMapper
protected $_dbTable;
- public function findBy($criteria, $value)
+ 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($criteria . ' = ?', $value);
+ ->where($where);
+
+ if(is_array($order)){
+ foreach ($order as $k => $v)
+ $a[] = "$k $v";
+ $select->order($a);
+ }
+
$stmt = $select->query();
$result = $stmt->fetchAll();
- return $result;
+
+ if(!$array){
+ $entries = array();
+ foreach ($result as $row) {
+ $entry = new Application_Model_PoolEntries($row);
+ $entry->setID($row['poolentriesID']);
+ $entries[] = $entry;
+ }
+ return $entries;
+ }else{
+ return $result;
+ }
+
}catch (Zend_Exception $e) {
echo "Error message 2: " . $e->getMessage() . "\n";
}
diff --git a/application/models/PoolMapper.php b/application/models/PoolMapper.php
index d809aff..d06dcbe 100644
--- a/application/models/PoolMapper.php
+++ b/application/models/PoolMapper.php
@@ -5,16 +5,43 @@ class Application_Model_PoolMapper
protected $_dbTable;
- public function findBy($criteria, $value)
+ 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($criteria . ' = ?', $value);
+ ->where($where);
+
+ if(is_array($order)){
+ foreach ($order as $k => $v)
+ $a[] = "$k $v";
+ $select->order($a);
+ }
+
$stmt = $select->query();
$result = $stmt->fetchAll();
- return $result;
+
+ if(!$array){
+ $entries = array();
+ foreach ($result as $row) {
+ $entry = new Application_Model_Pool($row);
+ $entry->setID($row['poolID']);
+ $entries[] = $entry;
+ }
+ return $entries;
+ }else{
+ return $result;
+ }
+
}catch (Zend_Exception $e) {
echo "Error message 2: " . $e->getMessage() . "\n";
}
diff --git a/application/models/PreBootMapper.php b/application/models/PreBootMapper.php
index 6053b19..28b8b04 100644
--- a/application/models/PreBootMapper.php
+++ b/application/models/PreBootMapper.php
@@ -5,25 +5,44 @@ class Application_Model_PreBootMapper
protected $_dbTable;
- public function findBy($criteria, $value)
+ 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($criteria . ' = ?', $value);
+ ->where($where);
+
+ if(is_array($order)){
+ foreach ($order as $k => $v)
+ $a[] = "$k $v";
+ $select->order($a);
+ }
+
$stmt = $select->query();
$result = $stmt->fetchAll();
- $entries = array();
- foreach ($result as $row) {
-
- $entry = new Application_Model_PreBoot($row);
- $entry->setID($row['prebootID']);
- $entries[] = $entry;
+ if(!$array){
+ $entries = array();
+ foreach ($result as $row) {
+ $entry = new Application_Model_PreBoot($row);
+ $entry->setID($row['prebootID']);
+ $entries[] = $entry;
+ }
+ return $entries;
+ }else{
+ return $result;
}
- return $entries;
+
}catch (Zend_Exception $e) {
echo "Error message 2: " . $e->getMessage() . "\n";
}
diff --git a/application/models/RightCategoryMapper.php b/application/models/RightCategoryMapper.php
index 1a3d093..4a7ca97 100644
--- a/application/models/RightCategoryMapper.php
+++ b/application/models/RightCategoryMapper.php
@@ -5,20 +5,47 @@ class Application_Model_RightCategoryMapper
protected $_dbTable;
- public function findBy($criteria, $value)
- {
- try{
+ 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($criteria . ' = ?', $value);
+ $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();
- return $result;
- }catch (Zend_Exception $e) {
- echo "Error message 2: " . $e->getMessage() . "\n";
+
+ if(!$array){
+ $entries = array();
+ foreach ($result as $row) {
+ $entry = new Application_Model_RightCategory($row);
+ $entry->setID($row['rightcategoryID']);
+ $entries[] = $entry;
+ }
+ return $entries;
+ }else{
+ return $result;
+ }
+
+ }catch (Zend_Exception $e) {
+ echo "Error message 2: " . $e->getMessage() . "\n";
}
- }
+ }
public function setDbTable($dbTable)
{
diff --git a/application/models/RightMapper.php b/application/models/RightMapper.php
index d59f518..5c0fef9 100644
--- a/application/models/RightMapper.php
+++ b/application/models/RightMapper.php
@@ -5,16 +5,43 @@ class Application_Model_RightMapper
protected $_dbTable;
- public function findBy($criteria, $value)
+ 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($criteria . ' = ?', $value);
+ ->where($where);
+
+ if(is_array($order)){
+ foreach ($order as $k => $v)
+ $a[] = "$k $v";
+ $select->order($a);
+ }
+
$stmt = $select->query();
$result = $stmt->fetchAll();
- return $result;
+
+ if(!$array){
+ $entries = array();
+ foreach ($result as $row) {
+ $entry = new Application_Model_Right($row);
+ $entry->setID($row['rightID']);
+ $entries[] = $entry;
+ }
+ return $entries;
+ }else{
+ return $result;
+ }
+
}catch (Zend_Exception $e) {
echo "Error message 2: " . $e->getMessage() . "\n";
}
diff --git a/application/models/RightRolesMapper.php b/application/models/RightRolesMapper.php
index 6557618..32ed666 100644
--- a/application/models/RightRolesMapper.php
+++ b/application/models/RightRolesMapper.php
@@ -5,20 +5,46 @@ class Application_Model_RightRolesMapper
protected $_dbTable;
- public function findBy($criteria, $value)
- {
- try{
+ 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($criteria . ' = ?', $value);
+ $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();
- return $result;
- }catch (Zend_Exception $e) {
- echo "Error message 2: " . $e->getMessage() . "\n";
+
+ if(!$array){
+ $entries = array();
+ foreach ($result as $row) {
+ $entry = new Application_Model_RightRoles($row);
+ $entries[] = $entry;
+ }
+ return $entries;
+ }else{
+ return $result;
+ }
+
+ }catch (Zend_Exception $e) {
+ echo "Error message 2: " . $e->getMessage() . "\n";
}
- }
+ }
public function setDbTable($dbTable)
{
diff --git a/application/models/RoleMapper.php b/application/models/RoleMapper.php
index 4001e3e..13ef789 100644
--- a/application/models/RoleMapper.php
+++ b/application/models/RoleMapper.php
@@ -5,16 +5,43 @@ class Application_Model_RoleMapper
protected $_dbTable;
- public function findBy($criteria, $value)
+ 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($criteria . ' = ?', $value);
+ ->where($where);
+
+ if(is_array($order)){
+ foreach ($order as $k => $v)
+ $a[] = "$k $v";
+ $select->order($a);
+ }
+
$stmt = $select->query();
$result = $stmt->fetchAll();
- return $result;
+
+ if(!$array){
+ $entries = array();
+ foreach ($result as $row) {
+ $entry = new Application_Model_Role($row);
+ $entry->setID($row['roleID']);
+ $entries[] = $entry;
+ }
+ return $entries;
+ }else{
+ return $result;
+ }
+
}catch (Zend_Exception $e) {
echo "Error message 2: " . $e->getMessage() . "\n";
}
diff --git a/application/models/SessionMapper.php b/application/models/SessionMapper.php
index 62740a0..d12a071 100644
--- a/application/models/SessionMapper.php
+++ b/application/models/SessionMapper.php
@@ -5,16 +5,43 @@ class Application_Model_SessionMapper
protected $_dbTable;
- public function findBy($criteria, $value)
+ 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($criteria . ' = ?', $value);
+ ->where($where);
+
+ if(is_array($order)){
+ foreach ($order as $k => $v)
+ $a[] = "$k $v";
+ $select->order($a);
+ }
+
$stmt = $select->query();
$result = $stmt->fetchAll();
- return $result;
+
+ if(!$array){
+ $entries = array();
+ foreach ($result as $row) {
+ $entry = new Application_Model_Session($row);
+ $entry->setID($row['sessionID']);
+ $entries[] = $entry;
+ }
+ return $entries;
+ }else{
+ return $result;
+ }
+
}catch (Zend_Exception $e) {
echo "Error message 2: " . $e->getMessage() . "\n";
}