public function getCommentCounts(array $ids, $recommended = false, $all = false)
{
$qb = $this->getRepository()->createQueryBuilder('c')->select('COUNT(c), c.thread')->andWhere('c.thread IN (:ids)')->andWhere('c.status = :status');
if (!$all) {
if ($recommended) {
$qb->andWhere('c.recommended = 1');
} else {
$qb->andWhere('c.recommended <> 1');
}
}
return $qb->groupBy('c.thread')->setParameter('ids', array_values($ids))->setParameter('status', Comment::STATUS_APPROVED)->getQuery()->getResult();
}