Commit e6dbc733 authored by romanb's avatar romanb

[2.0] Added remaining supported functions for 2.0.

parent ae5d2122
<?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(')');
}
}
<?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']);
}
}
<?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']);
}
}
<?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']);
}
}
<?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(')');
}
}
<?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(')');
}
}
<?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(')');
}
}
<?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(')');
}
}
<?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(')');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment