]> Raphaël G. Git Repositories - airbundle/commitdiff
Add findAllByLocationDatePeriod function
authorRaphaël Gertz <git@rapsys.eu>
Mon, 19 Oct 2020 01:40:22 +0000 (03:40 +0200)
committerRaphaël Gertz <git@rapsys.eu>
Mon, 19 Oct 2020 01:40:22 +0000 (03:40 +0200)
Repository/SessionRepository.php

index 9ffaf023e36ba8307942d0364cc92b4bfad051f4..b7471eb94e3dc591c92cde7862b238845102d964 100644 (file)
@@ -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;
+       }
 }