protected function build() { $this->select[] = 'event_information.*'; if ($this->country) { $this->where[] = " event_information.country_id = :country_id "; $this->params['country_id'] = $this->country->getId(); } if ($this->area) { // We were doing // $this->joins[] = " LEFT JOIN cached_area_has_parent ON cached_area_has_parent.area_id = venue_information.area_id"; // $this->where[] = " (venue_information.area_id = :area_id OR cached_area_has_parent.has_parent_area_id = :area_id )"; // but then we got duplicates $areaids = array($this->area->getId()); $this->statAreas = $this->siteContainer['databasehelper']->getPDO()->prepare("SELECT area_id FROM cached_area_has_parent WHERE has_parent_area_id=:id"); $this->statAreas->execute(array('id' => $this->area->getId())); while ($d = $this->statAreas->fetch()) { $areaids[] = $d['area_id']; } $this->where[] = " event_information.area_id IN (" . implode(",", $areaids) . ")"; } if ($this->group) { $this->joins[] = " JOIN event_in_group AS event_in_group ON event_in_group.event_id = event_information.id " . " AND event_in_group.group_id = :group_id "; $this->params['group_id'] = $this->group->getId(); } if ($this->after) { $this->where[] = ' event_information.end_at > :after'; $this->params['after'] = $this->after; } }
/** * @param mixed $country */ public function setCountry(CountryModel $country) { $this->country_id = $country->getId(); $this->country = $country; }