Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax error - Doctrine\ORM\Query\QueryException

This is the query I am using:

$q = $this->getEntityManager()->createQueryBuilder("SELECT e FROM ActionModule\Action e JOIN e.type t WHERE t.id IN (:ids)");

I have tried every parameter assigning option:

  • :ids
  • ?1
  • implode(',', $ids)
  • ?ids

And always get:

Doctrine\ORM\Query\QueryException

[Syntax Error] line 0, col -1: Error: Expected IdentificationVariable | ScalarExpression | AggregateExpression | FunctionDeclaration | PartialObjectExpression | "(" Subselect ")" | CaseExpression, got end of string

Thanks a lot in advance

EDIT:

I've dumped $q->getQuery()->getDql() and got: "SELECT" (6)

like image 488
peter.o Avatar asked Feb 07 '26 00:02

peter.o


1 Answers

createQueryBuilder doesn't accept any arguments and its purpose is creating queries using the builder methods, not DQL.

What you need is createQuery.

$q = $this->getEntityManager()->createQuery("SELECT e FROM ActionModule\Action e JOIN e.type t WHERE t.id IN (:ids)");
like image 143
meze Avatar answered Feb 12 '26 04:02

meze



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!