Browse files

date function bug fixed , now accept date and modifier

  • Loading branch information...
1 parent 57a2c0f commit 71dbad33f4ddd30a427f441c14b79017b66099dc @Mparaiso committed Apr 26, 2013
View
14 src/Mparaiso/Doctrine/ORM/Functions/Date.php
@@ -18,19 +18,31 @@ class Date extends FunctionNode
*/
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
- return "DATE(" .$this->date->dispatch($sqlWalker) . ")";
+ if (NULL != $this->modifier) {
+ return "DATE(" . $this->date->dispatch($sqlWalker) . "," . $this->modifier->dispatch($sqlWalker) . ")";
+ }
+ return "DATE(" . $this->date->dispatch($sqlWalker) . ")";
}
/**
* @override
*/
public function parse(\Doctrine\ORM\Query\Parser $parser)
{
+ $lexer = $parser->getLexer();
+
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$this->date = $parser->ArithmeticPrimary();
+ if (Lexer::T_COMMA === $lexer->lookahead['type']) {
+ $parser->match(Lexer::T_COMMA);
+ $this->modifier = $parser->ArithmeticPrimary();
+ }
+
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
+
+
}
}
View
2 src/Mparaiso/Provider/DoctrineORMServiceProvider.php
@@ -102,7 +102,7 @@ public function register(Application $app)
if (isset($app["orm.logger"])) {
$config->setSQLLogger($app["orm.logger"]);
}
- $config->addCustomDatetimeFunction("DATE", '\Mparaiso\Doctrine\ORM\Function\Date');
+ $config->addCustomDatetimeFunction("DATE", 'Mparaiso\Doctrine\ORM\Functions\Date');
return $config;
});
/**

0 comments on commit 71dbad3

Please sign in to comment.