summaryrefslogtreecommitdiffstats
path: root/application/models/RightRolesMapper.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/models/RightRolesMapper.php')
-rw-r--r--application/models/RightRolesMapper.php46
1 files changed, 36 insertions, 10 deletions
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)
{