Esempio n. 1
0
 public function loadByFilter($filterArgs = array(), $ufilterArgs = array())
 {
     $sql = array();
     $args = array();
     foreach ($filterArgs as $key => $value) {
         if ($property = $this->findDbKeyByProperty($key)) {
             if (is_array($value)) {
                 if (count($value)) {
                     foreach ($value as $vvalue) {
                         $args[] = $this->db->quote($vvalue);
                     }
                     $sql[] = "`{$property}` IN (" . implode(",", array_fill(0, count($value), "?")) . ")";
                 }
             } else {
                 $sql[] = "`{$property}` = ?";
                 $args[] = $value;
             }
         }
     }
     foreach ($ufilterArgs as $key => $value) {
         if ($property = $this->findDbKeyByProperty($key)) {
             if (is_array($value)) {
                 if (count($value)) {
                     foreach ($value as $vvalue) {
                         $args[] = $this->db->quote($vvalue);
                     }
                     $sql[] = "`{$key}` NOT IN (" . implode(",", array_fill(0, count($value), "?")) . ")";
                 }
             } else {
                 $sql[] = "`{$key}` != ?";
                 $args[] = $value;
             }
         }
     }
     $sqlString = "SELECT * FROM {$this->dbTableName}";
     if (count($sql)) {
         $sqlString .= " WHERE " . implode(" AND ", $sql);
     }
     //TODO: Return array of objects
     //die("TODO");
     return $this->db->GetAll($sqlString, $args);
 }