1
0
mirror of synced 2024-12-15 07:36:03 +03:00
doctrine2/lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php

71 lines
1.8 KiB
PHP
Raw Normal View History

<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
namespace Doctrine\ORM\Query\AST\Functions;
/**
* "LOCATE" "(" StringPrimary "," StringPrimary ["," SimpleArithmeticExpression]")"
*
* @author robo
*/
class LocateFunction extends FunctionNode
{
private $_firstStringPrimary;
private $_secondStringPrimary;
private $_simpleArithmeticExpression;
public function getFirstStringPrimary()
{
return $this->_firstStringPrimary;
}
public function getSecondStringPrimary()
{
return $this->_secondStringPrimary;
}
public function getSimpleArithmeticExpression()
{
return $this->_simpleArithmeticExpression;
}
/**
* @override
*/
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
//TODO: Use platform to get SQL
$sql = 'LOCATE(' .
$sqlWalker->walkStringPrimary($this->_firstStringPrimary)
. ', ' .
$sqlWalker->walkStringPrimary($this->_secondStringPrimary);
if ($this->_simpleArithmeticExpression) {
$sql .= ', ' . $sqlWalker->walkSimpleArithmeticExpression($this->_simpleArithmeticExpression);
}
return $sql . ')';
}
/**
* @override
*/
public function parse(\Doctrine\ORM\Query\Parser $parser)
{
$lexer = $parser->getLexer();
$parser->match($lexer->lookahead['value']);
$parser->match('(');
2009-06-14 21:34:28 +04:00
$this->_firstStringPrimary = $parser->StringPrimary();
$parser->match(',');
2009-06-14 21:34:28 +04:00
$this->_secondStringPrimary = $parser->StringPrimary();
if ($lexer->isNextToken(',')) {
$parser->match(',');
2009-06-14 21:34:28 +04:00
$this->_simpleArithmeticExpression = $parser->SimpleArithmeticExpression();
}
$parser->match(')');
}
}