]> Raphaƫl G. Git Repositories - airbundle/blob - Repository/SessionRepository.php
Replace location.index by session.index
[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
46 /**
47 * Find sessions by location and date period
48 *
49 * @param $location The location
50 * @param $period The date period
51 */
52 public function findAllByLocationDatePeriod($location, $period) {
53 //Fetch sessions
54 $ret = $this->getEntityManager()
55 ->createQuery('SELECT s FROM RapsysAirBundle:Session s WHERE (s.location = :location AND s.date BETWEEN :begin AND :end)')
56 ->setParameter('location', $location)
57 ->setParameter('begin', $period->getStartDate())
58 ->setParameter('end', $period->getEndDate())
59 ->getResult();
60
61 //Send result
62 return $ret;
63 }
64 }