2009-03-23 21:48:54 +03:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* To change this template, choose Tools | Templates
|
|
|
|
* and open the template in the editor.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Doctrine\ORM\Query\AST\Functions;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* "SQRT" "(" SimpleArithmeticExpression ")"
|
|
|
|
*
|
2009-06-14 21:34:28 +04:00
|
|
|
* @author Roman Borschel <roman@code-factory.org>
|
2009-03-23 21:48:54 +03:00
|
|
|
*/
|
|
|
|
class SqrtFunction extends FunctionNode
|
|
|
|
{
|
|
|
|
private $_simpleArithmeticExpression;
|
|
|
|
|
|
|
|
public function getSimpleArithmeticExpression()
|
|
|
|
{
|
|
|
|
return $this->_simpleArithmeticExpression;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @override
|
|
|
|
*/
|
|
|
|
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
|
|
|
|
{
|
|
|
|
//TODO: Use platform to get SQL
|
|
|
|
return 'SQRT(' . $sqlWalker->walkSimpleArithmeticExpression($this->_simpleArithmeticExpression) . ')';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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->_simpleArithmeticExpression = $parser->SimpleArithmeticExpression();
|
2009-03-23 21:48:54 +03:00
|
|
|
$parser->match(')');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|