I am trying to query the number of entries from a database using Doctrine.
$query = $em->createQuery('SELECT COUNT(p.id) FROM AppBundle:Product p where p.live = 1');
$count = $query->getSingleScalarResult();
I would like to extend the where clause and use "p.supplier == adidas".
How to add this to the query?
I could use
findBy(array("live" => 1, "supplier" => "adidas"))
but I surmise that findBy
is much slower than the direct Mysql query. Am I right?