示例#1
0
 protected function where_match(Q $q, array $self_columns)
 {
     $query = new Q();
     foreach ($q->arArg1() as $cond) {
         if (strpos($cond, "=") !== false) {
             list($column, $value) = explode("=", $cond);
             $not = substr($value, 0, 1) == "!";
             $value = $not ? strlen($value) > 1 ? substr($value, 1) : "" : $value;
             if ($value === "") {
                 $query->add($not ? Q::neq($column, "") : Q::eq($column, ""));
             } else {
                 $query->add($not ? Q::contains($column, $value, $q->param() | Q::NOT) : Q::contains($column, $value, $q->param()));
             }
         } else {
             $columns = array();
             foreach ($self_columns as $column) {
                 $columns[] = $column->name();
             }
             $query->add(Q::contains(implode(",", $columns), explode(" ", $cond), $q->param()));
         }
     }
     return $query;
 }