From: Raphaƫl Gertz Date: Mon, 19 Oct 2020 01:40:22 +0000 (+0200) Subject: Add findAllByLocationDatePeriod function X-Git-Tag: 0.1.2~2 X-Git-Url: https://git.rapsys.eu/airbundle/commitdiff_plain/e874335fb152dd842c9d156809b9910f9844f8b7?ds=sidebyside;hp=9ad438224accf84aa679e7ea22594f73054feb61 Add findAllByLocationDatePeriod function --- diff --git a/Repository/SessionRepository.php b/Repository/SessionRepository.php index 9ffaf02..b7471eb 100644 --- a/Repository/SessionRepository.php +++ b/Repository/SessionRepository.php @@ -42,4 +42,23 @@ class SessionRepository extends \Doctrine\ORM\EntityRepository { //Send result return $ret; } + + /** + * Find sessions by location and date period + * + * @param $location The location + * @param $period The date period + */ + public function findAllByLocationDatePeriod($location, $period) { + //Fetch sessions + $ret = $this->getEntityManager() + ->createQuery('SELECT s FROM RapsysAirBundle:Session s WHERE (s.location = :location AND s.date BETWEEN :begin AND :end)') + ->setParameter('location', $location) + ->setParameter('begin', $period->getStartDate()) + ->setParameter('end', $period->getEndDate()) + ->getResult(); + + //Send result + return $ret; + } }