/** * SelectExpression ::= * IdentificationVariable | StateFieldPathExpression | * (AggregateExpression | "(" Subselect ")" | FunctionDeclaration) [["AS"] AliasResultVariable] * * @return \Doctrine\ORM\Query\AST\SelectExpression */ public function SelectExpression() { $expression = null; $fieldAliasIdentificationVariable = null; $peek = $this->_lexer->glimpse(); // First we recognize for an IdentificationVariable (DQL class alias) if ($peek['value'] != '.' && $peek['value'] != '(' && $this->_lexer->lookahead['type'] === Lexer::T_IDENTIFIER) { $expression = $this->IdentificationVariable(); } else { if (($isFunction = $this->_isFunction()) !== false || $this->_isSubselect()) { if ($isFunction) { if ($this->_isAggregateFunction($this->_lexer->lookahead['type'])) { $expression = $this->AggregateExpression(); } else { $expression = $this->FunctionDeclaration(); } } else { $this->match(Lexer::T_OPEN_PARENTHESIS); $expression = $this->Subselect(); $this->match(Lexer::T_CLOSE_PARENTHESIS); } if ($this->_lexer->isNextToken(Lexer::T_AS)) { $this->match(Lexer::T_AS); } if ($this->_lexer->isNextToken(Lexer::T_IDENTIFIER)) { $token = $this->_lexer->lookahead; $fieldAliasIdentificationVariable = $this->AliasResultVariable(); // Include AliasResultVariable in query components. $this->_queryComponents[$fieldAliasIdentificationVariable] = array('resultVariable' => $expression, 'nestingLevel' => $this->_nestingLevel, 'token' => $token); } } else { // Deny hydration of partial objects if doctrine.forcePartialLoad query hint not defined if ($this->_query->getHydrationMode() == Query::HYDRATE_OBJECT && !$this->_query->getHint(Query::HINT_FORCE_PARTIAL_LOAD)) { throw DoctrineException::partialObjectsAreDangerous(); } $expression = $this->StateFieldPathExpression(); } } return new AST\SelectExpression($expression, $fieldAliasIdentificationVariable); }