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/GroupMapper.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/GroupMapper.php')
| -rw-r--r-- | application/models/GroupMapper.php | 26 |
1 files changed, 23 insertions, 3 deletions
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"; } |
