Skip to content

Instantly share code, notes, and snippets.

@spolischook
Last active August 29, 2015 14:16
Show Gist options
  • Save spolischook/2960104b7de815de1c6c to your computer and use it in GitHub Desktop.
Save spolischook/2960104b7de815de1c6c to your computer and use it in GitHub Desktop.
public function findByDateRangeAndSlug(\DateTime $fromDate, \DateTime $toDate, $performanceSlug = null)
{
$qb = $this->createQueryBuilder('u')
->WHERE('u.dateTime BETWEEN :from AND :to')
->setParameter('from', $fromDate->format('Y-m-d H:i'))
->setParameter('to', $toDate->format('Y-m-d H:i'))
->orderBy('u.dateTime', 'ASC')
;
if ($performanceSlug) {
$qb->join('u.performance', 'p')->andWhere('p.slug = :slug')->setParameter('slug', $performanceSlug);
}
$query = $qb->getQuery();
return $query->execute();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment