Esempio n. 1
0
 /**
  * @return  Collection
  */
 public function getGeocaches()
 {
     if (!$this->geocaches->isReady()) {
         $db = OcDb::instance();
         $query = 'SELECT powerTrail_caches.isFinal, caches . * , user.username FROM  `caches` , user, powerTrail_caches WHERE cache_id IN ( SELECT  `cacheId` FROM  `powerTrail_caches` WHERE  `PowerTrailId` =:1) AND user.user_id = caches.user_id AND powerTrail_caches.cacheId = caches.cache_id ORDER BY caches.name';
         $s = $db->multiVariableQuery($query, $this->id);
         $geoCachesDbResult = $db->dbResultFetchAll($s);
         $geocachesIdArray = array();
         foreach ($geoCachesDbResult as $geoCacheDbRow) {
             $geocache = new GeoCache();
             $geocache->loadFromRow($geoCacheDbRow)->setIsPowerTrailPart(true);
             $geocache->setPowerTrail($this);
             if ($geoCacheDbRow['isFinal'] == 1) {
                 $geocache->setIsPowerTrailFinalGeocache(true);
             }
             $this->geocaches[] = $geocache;
             $geocachesIdArray[] = $geocache->getCacheId();
         }
         $this->geocaches->setIsReady(true);
         $this->geocaches->setGeocachesIdArray($geocachesIdArray);
         $this->caculateGeocachesCountByStatus();
     }
     return $this->geocaches;
 }