]> Raphaƫl G. Git Repositories - airbundle/blob - Repository/SessionRepository.php
Update fr translations
[airbundle] / Repository / SessionRepository.php
1 <?php
2
3 namespace Rapsys\AirBundle\Repository;
4
5 /**
6 * SessionRepository
7 */
8 class SessionRepository extends \Doctrine\ORM\EntityRepository {
9 /**
10 * Find session by location, slot and date
11 *
12 * @param $location The location
13 * @param $slot The slot
14 * @param $date The datetime
15 */
16 public function findOneByLocationSlotDate($location, $slot, $date) {
17 //Fetch session
18 $ret = $this->getEntityManager()
19 ->createQuery('SELECT s FROM RapsysAirBundle:Session s WHERE (s.location = :location AND s.slot = :slot AND s.date = :date)')
20 ->setParameter('location', $location)
21 ->setParameter('slot', $slot)
22 ->setParameter('date', $date)
23 ->getSingleResult();
24
25 //Send result
26 return $ret;
27 }
28
29 /**
30 * Find sessions by date period
31 *
32 * @param $period The date period
33 */
34 public function findAllByDatePeriod($period) {
35 //Fetch sessions
36 $ret = $this->getEntityManager()
37 ->createQuery('SELECT s FROM RapsysAirBundle:Session s WHERE s.date BETWEEN :begin AND :end')
38 ->setParameter('begin', $period->getStartDate())
39 ->setParameter('end', $period->getEndDate())
40 ->getResult();
41
42 //Send result
43 return $ret;
44 }
45 }