Created
December 2, 2011 10:57
-
-
Save haswalt/1422794 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% for competition in competitions %} | |
<tr> | |
<td>{{ competition.title }}</td> | |
<td>{{ competition.searchPhrase }}</td> | |
<td>{{ competition.openAt|date }}</td> | |
<td>{{ competition.closeAt|date }}</td> | |
<td>{{ competition.total }}</td> | |
</tr> | |
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Doctrine\ORM\EntityRepository; | |
/** | |
* CompetitionRepository | |
* | |
* This class was generated by the Doctrine ORM. Add your own custom | |
* repository methods below. | |
*/ | |
class CompetitionRepository extends EntityRepository | |
{ | |
public function findAllWithCount() | |
{ | |
$qb = $this->createQueryBuilder('c'); | |
$qb->select('c.id, c.title, c.searchPhrase, c.openAt, c.closeAt, COUNT(e.competition) AS total, c.winnerId') | |
->leftJoin('c.entries', 'e') | |
->groupBy('c.id, c.title, c.searchPhrase, c.openAt, c.closeAt, c.winnerId, e.competition') | |
->orderBy('c.openAt'); | |
return $qb->getQuery()->getArrayResult(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Test comment