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);
     $query->field($fieldName);
     switch ($operator) {
         case '=':
             $query->equals($value, $options);
             break;
         case '!=':
             $query->notEqual($value, $options);
             break;
         case '>=':
             $query->greaterThanOrEq($value, $options);
             break;
         case '<=':
             $query->lessThanOrEq($value, $options);
             break;
         case '>':
             $query->greaterThan($value, $options);
             break;
         case '<':
             $query->lessThan($value, $options);
             break;
         case 'in':
             $query->in($value, $options);
             break;
         case 'notIn':
             $query->notIn($value, $options);
             break;
         case 'all':
             $query->all($value, $options);
             break;
         case 'size':
             $query->size($value, $options);
             break;
         case 'exists':
             $query->exists($value, $options);
             break;
         case 'type':
             $query->type($value, $options);
             break;
         case 'mod':
             $query->mod($value, $options);
             break;
         default:
             $this->syntaxError('Invalid atomic update operator.');
     }
 }