Hello,
I need to translate `WEEK(DATE_SUB(CURRENT_DATE(), INTERVAL 1 WEEK))` to
DQL:
It looks like this for the moment: `WEEK_NUMBER(DATE_SUB(my_var , 7, DAY) `
```
class WeekNumber extends FunctionNode
{
/**
* @var AggregateExpression|FunctionNode|InputParameter|string
*/
public $dateTimeExpression = null;
/**
* {@inheritdoc}
*/
public function parse(Parser $parser)
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$this->dateTimeExpression = $parser->ArithmeticPrimary();
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
}
/**
* {@inheritdoc}
*/
public function getSql(SqlWalker $sqlWalker)
{
return 'WEEK(' .
$this->dateTimeExpression->dispatch($sqlWalker)
. ')';
}
=> It generates me an error: Uncaught PHP Exception
Doctrine\ORM\Query\QueryException: "[Syntax Error] line 0, col 134: Error:
Expected '.' or '(', got 'DAY'" ..
Seems like `ArithmeticPrimary()` does'nt support `DATE_SUB` expression :S
Any help please!
Thanks,
--
You received this message because you are subscribed to the Google Groups
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.