. */ namespace Doctrine\ORM\Query\AST\Functions; use Doctrine\ORM\Query\Lexer; /** * "LOCATE" "(" StringPrimary "," StringPrimary ["," SimpleArithmeticExpression]")" * * * @link www.doctrine-project.org * @since 2.0 * @author Guilherme Blanco * @author Jonathan Wage * @author Roman Borschel * @author Benjamin Eberlei */ class LocateFunction extends FunctionNode { public $firstStringPrimary; public $secondStringPrimary; /** * @var \Doctrine\ORM\Query\AST\SimpleArithmeticExpression|bool */ public $simpleArithmeticExpression = false; /** * @override */ public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) { return $sqlWalker->getConnection()->getDatabasePlatform()->getLocateExpression( $sqlWalker->walkStringPrimary($this->secondStringPrimary), // its the other way around in platform $sqlWalker->walkStringPrimary($this->firstStringPrimary), (($this->simpleArithmeticExpression) ? $sqlWalker->walkSimpleArithmeticExpression($this->simpleArithmeticExpression) : false ) ); } /** * @override */ public function parse(\Doctrine\ORM\Query\Parser $parser) { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); $this->firstStringPrimary = $parser->StringPrimary(); $parser->match(Lexer::T_COMMA); $this->secondStringPrimary = $parser->StringPrimary(); $lexer = $parser->getLexer(); if ($lexer->isNextToken(Lexer::T_COMMA)) { $parser->match(Lexer::T_COMMA); $this->simpleArithmeticExpression = $parser->SimpleArithmeticExpression(); } $parser->match(Lexer::T_CLOSE_PARENTHESIS); } }