Exemplo n.º 1
0
 /**
  * WhereClausePart ::= ["all", "not"] DocumentFieldName WhereClauseExpression Value
  * WhereClauseExpression ::= "=" | "!=" | ">=" | "<=" | ">" | "<" | "in"
  *                         "notIn" | "all" | "size" | "exists" | "type"
  */
 public function WhereClauseExpression(Query $query, array &$parameters)
 {
     $options = array();
     switch ($this->_lexer->lookahead['type']) {
         case Lexer::T_ALL:
             $this->match(Lexer::T_ALL);
             $options['elemMatch'] = true;
             break;
         case Lexer::T_NOT:
             $this->match(Lexer::T_NOT);
             $options['not'] = true;
             break;
     }
     $fieldName = $this->DocumentFieldName();
     $operator = $this->_lexer->lookahead['value'];
     $value = $this->Value($parameters);
     switch ($operator) {
         case '=':
             $query->where($fieldName, $value, $options);
             break;
         case '!=':
             $query->whereNotEqual($fieldName, $value, $options);
             break;
         case '>=':
             $query->whereGte($fieldName, $value, $options);
             break;
         case '<=':
             $query->whereLte($fieldName, $value, $options);
             break;
         case '>':
             $query->whereGt($fieldName, $value, $options);
             break;
         case '<':
             $query->whereLt($fieldName, $value, $options);
             break;
         case 'in':
             $query->whereIn($fieldName, $value, $options);
             break;
         case 'notIn':
             $query->whereNotIn($fieldName, $value, $options);
             break;
         case 'all':
             $query->whereAll($fieldName, $value, $options);
             break;
         case 'size':
             $query->whereSize($fieldName, $value, $options);
             break;
         case 'exists':
             $query->whereExists($fieldName, $value, $options);
             break;
         case 'type':
             $query->whereType($fieldName, $value, $options);
             break;
         case 'mod':
             $query->whereMod($fieldName, $value, $options);
             break;
         default:
             $this->syntaxError('Invalid atomic update operator.');
     }
 }