I have a table in the db where I can count the total number of records in the table where imagefk is equal to the parameter given. Here is a possible structure of the table
id | reviews | bookname | imagefk
1 | 1 | xyz | null
2 | 1 | xyz | 53
3 | 1 | xyz | 53
Using below to return the total count of reviews where imagefk is equal to the parameter given, it returns all records instead of the three rows
public function getAllImagesAction(String imagefk)
{
$entityManager = $this->getDoctrine()->getManager();
$qb = $entityManager->createQueryBuilder();
$qb->select('count(e.reviews)');
$qb->from('xxxBundle:Books','e')
->add('where', 'e.imagefk = imagefk'); // making the parameter dynamic and to pull from the url routing.yml file
$count = $qb->getQuery()->getSingleScalarResult();
my challenge with the above query is that the where clause does not count 2 records based on this parameter
instead it counts 3 records. Please what could be wrong. Kindly assist