` "[Syntax Error] line 0, col 134` Please provide:
* your DQL * your expected SQL Also, I would strongly suggest to write an integration test relying on the DQL parser ;-) Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On Mon, Jan 23, 2017 at 12:17 PM, Abir BRAHEM <[email protected]> wrote: > 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. > -- 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.
