Esempio n. 1
0
 /**
  * findUsersByCity
  *
  * @param \Application\CityBundle\Entity\City $city
  * @param int $max
  * @access public
  * @return \Doctrine\Common\ArrayCollection
  */
 public function findUsersByCity(\Application\CityBundle\Entity\City $city, $max = 10)
 {
     return $this->_em->createQueryBuilder()->add('select', 'u')->add('from', 'ApplicationUserBundle:User u')->andWhere('u.city_id = :id')->setParameter('id', $city->getId())->add('orderBy', 'u.date_login DESC')->setMaxResults($max)->getQuery()->getResult();
 }
Esempio n. 2
0
 /**
  * findEventsByCityDQL
  *
  * @param \DateTime $date
  * @param \Application\CityBundle\Entity\City $city
  * @param int $type
  * @access public
  * @return Doctrine DQL
  */
 public function findEventsByCityDQL(\DateTime $date, \Application\CityBundle\Entity\City $city, $type = false)
 {
     $query = $this->_em->createQueryBuilder()->add('select', 'e')->add('from', 'ApplicationEventBundle:Event e')->andWhere('e.date_start > :date')->setParameter('date', $date->format('Y-m-d'))->andWhere('e.city_id = :city_id')->setParameter('city_id', $city->getId());
     if (is_numeric($type)) {
         $query->andWhere('e.type = :type')->setParameter('type', $type);
     }
     $query->add('orderBy', 'e.featured DESC, e.date_start ASC');
     return $query;
 }