0

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?

4

1 回答 1

0

您没有指定“类别”参数值。请参阅Doctrine DQL用法。

前任。

$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();
于 2013-07-17T00:36:57.330 回答