Doctrine\ORM\Query\Parser::ArithmeticExpression PHP Method

ArithmeticExpression() public method

ArithmeticExpression ::= SimpleArithmeticExpression | "(" Subselect ")"
public ArithmeticExpression ( ) : Doctrine\ORM\Query\AST\ArithmeticExpression
return Doctrine\ORM\Query\AST\ArithmeticExpression
    public function ArithmeticExpression()
    {
        $expr = new AST\ArithmeticExpression;

        if ($this->_lexer->isNextToken(Lexer::T_OPEN_PARENTHESIS)) {
            $peek = $this->_lexer->glimpse();

            if ($peek['type'] === Lexer::T_SELECT) {
                $this->match(Lexer::T_OPEN_PARENTHESIS);
                $expr->subselect = $this->Subselect();
                $this->match(Lexer::T_CLOSE_PARENTHESIS);

                return $expr;
            }
        }

        $expr->simpleArithmeticExpression = $this->SimpleArithmeticExpression();

        return $expr;
    }

Usage Example

Ejemplo n.º 1
0
 public function parse(\Doctrine\ORM\Query\Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     // Add the concat separator to the values array.
     $this->values[] = $parser->ArithmeticExpression();
     // Add the rest of the strings to the values array. CONCAT_WS must
     // be used with at least 2 strings not including the separator.
     $lexer = $parser->getLexer();
     while (count($this->values) < 3 || $lexer->lookahead['type'] == Lexer::T_COMMA) {
         $parser->match(Lexer::T_COMMA);
         $peek = $lexer->glimpse();
         $this->values[] = $peek['value'] == '(' ? $parser->FunctionDeclaration() : $parser->ArithmeticExpression();
     }
     while ($lexer->lookahead['type'] == Lexer::T_IDENTIFIER) {
         switch (strtolower($lexer->lookahead['value'])) {
             case 'notempty':
                 $parser->match(Lexer::T_IDENTIFIER);
                 $this->notEmpty = true;
                 break;
             default:
                 // Identifier not recognized (causes exception).
                 $parser->match(Lexer::T_CLOSE_PARENTHESIS);
                 break;
         }
     }
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
All Usage Examples Of Doctrine\ORM\Query\Parser::ArithmeticExpression
Parser