Skip to content

Instantly share code, notes, and snippets.

@dfeyer
Created July 22, 2013 14:33
Show Gist options
  • Save dfeyer/6054287 to your computer and use it in GitHub Desktop.
Save dfeyer/6054287 to your computer and use it in GitHub Desktop.
<?php
namespace Ttree\Medialib\Analytics\Query\AST;
/* *
* This script belongs to the FLOW3 package "Ttree.Medialib". *
* *
* */
use TYPO3\Flow\Annotations as Flow;
use \Doctrine\ORM\Query\AST\Functions\FunctionNode;
use \Doctrine\ORM\Query\Lexer;
class MysqlCeil extends FunctionNode {
public $simpleArithmeticExpression;
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) {
return 'CEIL(' . $sqlWalker->walkSimpleArithmeticExpression(
$this->simpleArithmeticExpression
) . ')';
}
public function parse(\Doctrine\ORM\Query\Parser $parser) {
$lexer = $parser->getLexer();
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$this->simpleArithmeticExpression = $parser->SimpleArithmeticExpression();
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
}
}
?>
@dfeyer
Copy link
Author

dfeyer commented Jul 22, 2013

$config = $this->entityManager->getConfiguration();
$config->addCustomNumericFunction('CEIL', 'Ttree\Medialib\Analytics\Query\AST\MysqlCeil');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment