[2.0] Added remaining supported functions for 2.0.
This commit is contained in:
parent
ae5d212271
commit
e6dbc733c5
44
lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php
Normal file
44
lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
namespace Doctrine\ORM\Query\AST\Functions;
|
||||
|
||||
/**
|
||||
* "ABS" "(" SimpleArithmeticExpression ")"
|
||||
*
|
||||
* @author robo
|
||||
*/
|
||||
class AbsFunction 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 'ABS(' . $sqlWalker->walkSimpleArithmeticExpression($this->_simpleArithmeticExpression) . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
public function parse(\Doctrine\ORM\Query\Parser $parser)
|
||||
{
|
||||
$lexer = $parser->getLexer();
|
||||
$parser->match($lexer->lookahead['value']);
|
||||
$parser->match('(');
|
||||
$this->_simpleArithmeticExpression = $parser->_SimpleArithmeticExpression();
|
||||
$parser->match(')');
|
||||
}
|
||||
}
|
||||
|
34
lib/Doctrine/ORM/Query/AST/Functions/CurrentDateFunction.php
Normal file
34
lib/Doctrine/ORM/Query/AST/Functions/CurrentDateFunction.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
namespace Doctrine\ORM\Query\AST\Functions;
|
||||
|
||||
/**
|
||||
* "CURRENT_DATE"
|
||||
*
|
||||
* @author robo
|
||||
*/
|
||||
class CurrentDateFunction extends FunctionNode
|
||||
{
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
|
||||
{
|
||||
//TODO: Use platform to get SQL
|
||||
return 'CURRENT_DATE';
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
public function parse(\Doctrine\ORM\Query\Parser $parser)
|
||||
{
|
||||
$lexer = $parser->getLexer();
|
||||
$parser->match($lexer->lookahead['value']);
|
||||
}
|
||||
}
|
||||
|
34
lib/Doctrine/ORM/Query/AST/Functions/CurrentTimeFunction.php
Normal file
34
lib/Doctrine/ORM/Query/AST/Functions/CurrentTimeFunction.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
namespace Doctrine\ORM\Query\AST\Functions;
|
||||
|
||||
/**
|
||||
* "CURRENT_TIME"
|
||||
*
|
||||
* @author robo
|
||||
*/
|
||||
class CurrentTimeFunction extends FunctionNode
|
||||
{
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
|
||||
{
|
||||
//TODO: Use platform to get SQL
|
||||
return 'CURRENT_TIME';
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
public function parse(\Doctrine\ORM\Query\Parser $parser)
|
||||
{
|
||||
$lexer = $parser->getLexer();
|
||||
$parser->match($lexer->lookahead['value']);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
namespace Doctrine\ORM\Query\AST\Functions;
|
||||
|
||||
/**
|
||||
* "CURRENT_TIMESTAMP"
|
||||
*
|
||||
* @author robo
|
||||
*/
|
||||
class CurrentTimestampFunction extends FunctionNode
|
||||
{
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
|
||||
{
|
||||
//TODO: Use platform to get SQL
|
||||
return 'CURRENT_TIMESTAMP';
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
public function parse(\Doctrine\ORM\Query\Parser $parser)
|
||||
{
|
||||
$lexer = $parser->getLexer();
|
||||
$parser->match($lexer->lookahead['value']);
|
||||
}
|
||||
}
|
||||
|
44
lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php
Normal file
44
lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
namespace Doctrine\ORM\Query\AST\Functions;
|
||||
|
||||
/**
|
||||
* "LENGTH" "(" StringPrimary ")"
|
||||
*
|
||||
* @author robo
|
||||
*/
|
||||
class LengthFunction extends FunctionNode
|
||||
{
|
||||
private $_stringPrimary;
|
||||
|
||||
public function getStringPrimary()
|
||||
{
|
||||
return $this->_stringPrimary;
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
|
||||
{
|
||||
//TODO: Use platform to get SQL
|
||||
return 'LENGTH(' . $sqlWalker->walkStringPrimary($this->_stringPrimary) . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
public function parse(\Doctrine\ORM\Query\Parser $parser)
|
||||
{
|
||||
$lexer = $parser->getLexer();
|
||||
$parser->match($lexer->lookahead['value']);
|
||||
$parser->match('(');
|
||||
$this->_stringPrimary = $parser->_StringPrimary();
|
||||
$parser->match(')');
|
||||
}
|
||||
}
|
||||
|
70
lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php
Normal file
70
lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?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('(');
|
||||
$this->_firstStringPrimary = $parser->_StringPrimary();
|
||||
$parser->match(',');
|
||||
$this->_secondStringPrimary = $parser->_StringPrimary();
|
||||
if ($lexer->isNextToken(',')) {
|
||||
$parser->match(',');
|
||||
$this->_simpleArithmeticExpression = $parser->_SimpleArithmeticExpression();
|
||||
}
|
||||
$parser->match(')');
|
||||
}
|
||||
}
|
||||
|
56
lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php
Normal file
56
lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
namespace Doctrine\ORM\Query\AST\Functions;
|
||||
|
||||
/**
|
||||
* "MOD" "(" SimpleArithmeticExpression "," SimpleArithmeticExpression ")"
|
||||
*
|
||||
* @author robo
|
||||
*/
|
||||
class ModFunction extends FunctionNode
|
||||
{
|
||||
private $_firstSimpleArithmeticExpression;
|
||||
private $_secondSimpleArithmeticExpression;
|
||||
|
||||
public function getFirstSimpleArithmeticExpression()
|
||||
{
|
||||
return $this->_firstSimpleArithmeticExpression;
|
||||
}
|
||||
|
||||
public function getSecondSimpleArithmeticExpression()
|
||||
{
|
||||
return $this->_secondSimpleArithmeticExpression;
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
|
||||
{
|
||||
//TODO: Use platform to get SQL
|
||||
return 'SQRT(' .
|
||||
$sqlWalker->walkSimpleArithmeticExpression($this->_firstSimpleArithmeticExpression)
|
||||
. ', ' .
|
||||
$sqlWalker->walkSimpleArithmeticExpression($this->_secondSimpleArithmeticExpression)
|
||||
. ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
public function parse(\Doctrine\ORM\Query\Parser $parser)
|
||||
{
|
||||
$lexer = $parser->getLexer();
|
||||
$parser->match($lexer->lookahead['value']);
|
||||
$parser->match('(');
|
||||
$this->_firstSimpleArithmeticExpression = $parser->_SimpleArithmeticExpression();
|
||||
$parser->match(',');
|
||||
$this->_secondSimpleArithmeticExpression = $parser->_SimpleArithmeticExpression();
|
||||
$parser->match(')');
|
||||
}
|
||||
}
|
||||
|
44
lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php
Normal file
44
lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
namespace Doctrine\ORM\Query\AST\Functions;
|
||||
|
||||
/**
|
||||
* "SIZE" "(" CollectionValuedPathExpression ")"
|
||||
*
|
||||
* @author robo
|
||||
*/
|
||||
class SizeFunction extends FunctionNode
|
||||
{
|
||||
private $_collectionPathExpression;
|
||||
|
||||
public function getCollectionPathExpression()
|
||||
{
|
||||
return $this->_collectionPathExpression;
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
|
||||
{
|
||||
//TODO: Construct appropriate SQL
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
public function parse(\Doctrine\ORM\Query\Parser $parser)
|
||||
{
|
||||
$lexer = $parser->getLexer();
|
||||
$parser->match($lexer->lookahead['value']);
|
||||
$parser->match('(');
|
||||
$this->_collectionPathExpression = $parser->_CollectionValuedPathExpression();
|
||||
$parser->match(')');
|
||||
}
|
||||
}
|
||||
|
44
lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php
Normal file
44
lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
namespace Doctrine\ORM\Query\AST\Functions;
|
||||
|
||||
/**
|
||||
* "SQRT" "(" SimpleArithmeticExpression ")"
|
||||
*
|
||||
* @author robo
|
||||
*/
|
||||
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('(');
|
||||
$this->_simpleArithmeticExpression = $parser->_SimpleArithmeticExpression();
|
||||
$parser->match(')');
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user