Skip to content

Instantly share code, notes, and snippets.

Created December 21, 2012 14:02
Show Gist options
  • Save anonymous/4353014 to your computer and use it in GitHub Desktop.
Save anonymous/4353014 to your computer and use it in GitHub Desktop.
doctrine code
$publications = $user->getUserPublicationsAsArray();
$week = $this->getCurrentWeek();
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select(array('a', 'count(a) as amount'))
->from('Admin\Entity\Advert', 'a')
->where('a.fordate >= '.date('Y-m-d', $week['to']))
->andWhere($qb->expr()->in('a.publication', $publications))
->groupBy('a.advertType, a.publication, a.fordate, a.created');
$this->getLogger()->info($qb->getQuery()->getSQL());
return $qb->getQuery()->getResult();
SELECT a0_.advert_id AS advert_id0, a0_.fordate AS fordate1, a0_.created AS created2, count(a0_.advert_id) AS sclr3, a0_.publication_id AS publication_id4, a0_.advert_type_id AS advert_type_id5, a0_.mandator_id AS mandator_id6 FROM advert a0_ WHERE a0_.fordate >= 2013 - 01 - 14 AND a0_.publication_id IN (6, 7) GROUP BY a0_.advert_type_id, a0_.publication_id, a0_.fordate, a0_.created
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment