--- a/Entity/TagRepository.php Thu Feb 23 18:52:59 2012 +0100
+++ b/Entity/TagRepository.php Fri Feb 24 10:55:01 2012 +0100
@@ -1,4 +1,12 @@
<?php
+/*
+ * This file is part of the WikiTagBundle package.
+ *
+ * (c) IRI <http://www.iri.centrepompidou.fr/>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
namespace IRI\Bundle\WikiTagBundle\Entity;
@@ -36,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),"%_"))),