I have a Subscribers table which consists of emails (not unique) and a category for each email. I am trying to find the emails for each category using the following function but get the error:
Invalid parameter number: number of bound variables does not match number of tokens
This is my function:
public function findEmailsByCategory($category)
{
$result = $this->getEntityManager()
->createQuery(
'SELECT s.email FROM NEWSBlogBundle:Subscribers s WHERE s.category =:category'
)->getResult();
return $result;
}
Can anyone tell me where I'm going wrong?
You didn't specified "category" parameter value. Please see Doctrine DQL usage.
ex.
$query = $em->createQuery('SELECT u FROM ForumUser u WHERE u.username = :name');
$query->setParameter('name', 'Bob'); // you didn't add required parameter.
$users = $query->getResult();