コード例 #1
0
 /**
  *
  *
  */
 public function buildCacheAreaHasParent(AreaModel $area)
 {
     $statFirstArea = $this->siteContainer['databasehelper']->getPDO()->prepare("SELECT area_information.parent_area_id FROM area_information WHERE area_information.id=:id");
     // get first parent
     $areaParentID = null;
     $statFirstArea->execute(array('id' => $area->getId()));
     $d = $statFirstArea->fetch();
     if ($d) {
         $areaParentID = $d['parent_area_id'];
     }
     $statInsertCache = $this->siteContainer['databasehelper']->getPDO()->prepare("INSERT INTO cached_area_has_parent(area_id,has_parent_area_id) VALUES (:area_id,:has_parent_area_id)");
     $statNextArea = $this->siteContainer['databasehelper']->getPDO()->prepare("SELECT area_information.parent_area_id FROM area_information WHERE area_information.id=:id");
     while ($areaParentID) {
         // insert this parent into the cache
         $statInsertCache->execute(array('area_id' => $area->getId(), 'has_parent_area_id' => $areaParentID));
         // move up to next parent
         $statNextArea->execute(array('id' => $areaParentID));
         $d = $statNextArea->fetch();
         if ($d) {
             $areaParentID = $d['parent_area_id'];
         } else {
             $areaParentID = null;
         }
     }
 }
 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;
     }
 }
 protected function build()
 {
     $this->select[] = 'area_information.*';
     if ($this->country) {
         $this->where[] = " area_information.country_id = :country_id ";
         $this->params['country_id'] = $this->country->getId();
     }
     if ($this->noParentArea) {
         $this->where[] = ' area_information.parent_area_id IS null ';
     } else {
         if ($this->parentArea) {
             $this->where[] = " area_information.parent_area_id = :parent_id ";
             $this->params['parent_id'] = $this->parentArea->getId();
         }
     }
 }
コード例 #4
0
 /**
  * @param mixed $area
  */
 public function setArea(AreaModel $area)
 {
     $this->area_id = $area->getId();
     $this->area = $area;
 }