Exemplo n.º 1
0
 /**
  * SelectField ::= DocumentFieldName
  */
 public function SelectField(Query $query)
 {
     $fieldName = $this->DocumentFieldName();
     $limit = null;
     $skip = null;
     while ($this->_lexer->isNextToken($this->_lexer->lookahead['type'])) {
         switch ($this->_lexer->lookahead['type']) {
             case Lexer::T_SKIP:
                 $this->match(Lexer::T_SKIP);
                 $this->match(Lexer::T_INTEGER);
                 $skip = $this->_lexer->token['value'];
                 break;
             case Lexer::T_LIMIT:
                 $this->match(Lexer::T_LIMIT);
                 $this->match(Lexer::T_INTEGER);
                 $limit = $this->_lexer->token['value'];
                 break;
             default:
                 break 2;
         }
     }
     if ($skip || $limit) {
         $skip = $skip !== null ? $skip : 0;
         $query->selectSlice($fieldName, $skip, $limit);
     } else {
         $query->select($fieldName);
     }
 }
Exemplo n.º 2
0
 /**
  * SelectField ::= DocumentFieldName
  */
 public function SelectField(Query $query)
 {
     if ($this->lexer->isNextToken(Lexer::T_DISTINCT)) {
         $this->match(Lexer::T_DISTINCT);
         $fieldName = $this->DocumentFieldName();
         $query->distinct($fieldName);
         if (!$this->lexer->isNextToken(Lexer::T_IDENTIFIER) && !$this->lexer->isNextToken(Lexer::T_FROM)) {
             $this->syntaxError($this->lexer->getLiteral(Lexer::T_IDENTIFIER));
         }
         return;
     } else {
         $fieldName = $this->DocumentFieldName();
     }
     $limit = null;
     $skip = null;
     while ($this->lexer->isNextToken($this->lexer->lookahead['type'])) {
         switch ($this->lexer->lookahead['type']) {
             case Lexer::T_SKIP:
                 $this->match(Lexer::T_SKIP);
                 $this->match(Lexer::T_INTEGER);
                 $skip = $this->lexer->token['value'];
                 break;
             case Lexer::T_LIMIT:
                 $this->match(Lexer::T_LIMIT);
                 $this->match(Lexer::T_INTEGER);
                 $limit = $this->lexer->token['value'];
                 break;
             default:
                 break 2;
         }
     }
     if ($skip || $limit) {
         $skip = $skip !== null ? $skip : 0;
         $query->selectSlice($fieldName, $skip, $limit);
     } else {
         $query->select($fieldName);
     }
 }