--- a/Entity/TagRepository.php Tue Feb 21 15:15:22 2012 +0100
+++ b/Entity/TagRepository.php Thu Feb 23 23:02:07 2012 +0100
@@ -44,8 +44,10 @@
public function getCompletion($seed)
{
$qb = $this->getEntityManager()->createQueryBuilder();
- $qb->select('DISTINCT t.label');
+ $qb->select('t.label', 'COUNT(dt.id) AS nb_docs');
$qb->from('WikiTagBundle:Tag','t');
+ $qb->leftJoin('t.documents', 'dt', 'WITH', 't = dt.tag');
+ $qb->addGroupBy('t.label');
$qb->where($qb->expr()->orx(
$qb->expr()->like('t.label',$qb->expr()->literal(addcslashes(mysql_real_escape_string($seed),"%_")."%")),
$qb->expr()->like('t.label',$qb->expr()->literal("%".addcslashes(mysql_real_escape_string($seed),"%_"))),