Reputation: 2180
I'm running this DQL statement:
return $this->getEntityManager()
->createQuery("SELECT s FROM Bundle:table s WHERE s.title LIKE '%:search%'")
->setParameter('search', $search)
->getResult();
But I'm getting this error:
Invalid parameter number: number of bound variables does not match number of tokens
Anyone know what I'm doing wrong?
Upvotes: 0
Views: 154
Reputation: 34107
You cannot use variable substitution like that. Try this:
return $this->getEntityManager()
->createQuery("SELECT s FROM Bundle:table s WHERE s.title LIKE :search")
->setParameter('search', "%" . $search . "%")
->getResult();
Upvotes: 1
Reputation: 2333
Apparently Bundle:table
is not a correct reference to a bundle and an entity in your project. Check the spelling and camelCase of your Bundle / entity (or Entity ?) name.
Upvotes: 0