diff options
| author | michael pereira | 2011-04-04 17:12:48 +0200 |
|---|---|---|
| committer | michael pereira | 2011-04-04 17:12:48 +0200 |
| commit | 8ceb7bad18f257127ad5790a9c0ec157d7e03f4d (patch) | |
| tree | a83b3d35741914087db7eb8c169c1f5c3b0bd02a /application/models/BootMenuEntriesMapper.php | |
| parent | getRessoources bei Play werden angezeigt (diff) | |
| download | pbs2-8ceb7bad18f257127ad5790a9c0ec157d7e03f4d.tar.gz pbs2-8ceb7bad18f257127ad5790a9c0ec157d7e03f4d.tar.xz pbs2-8ceb7bad18f257127ad5790a9c0ec157d7e03f4d.zip | |
WICHTIG findBy Methode geändert & alles angepasst, siehe Ticket
Diffstat (limited to 'application/models/BootMenuEntriesMapper.php')
| -rw-r--r-- | application/models/BootMenuEntriesMapper.php | 52 |
1 files changed, 25 insertions, 27 deletions
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"; |
