public function getGeocaches() { if ($this->geocaches === null) { $this->geocaches = new \ArrayObject(); $db = OcDb::instance(); $stmt = $db->multiVariableQuery("SELECT * FROM `caches` where `user_id` = :1 ", $this->userId); foreach ($db->dbResultFetchAll($stmt) as $geocacheRow) { $geocache = new GeoCache(); $geocache->loadFromRow($geocacheRow); $this->geocaches->append($geocache); if ($geocache->getStatus() === GeoCache::STATUS_NOTYETAVAILABLE) { $this->appendNotPublishedGeocache($geocache); } if ($geocache->getStatus() === GeoCache::STATUS_WAITAPPROVERS) { $this->appendWaitAprooveGeocache($geocache); } if ($geocache->getStatus() === GeoCache::STATUS_BLOCKED) { $this->appendBlockedGeocache($geocache); } } } return $this->geocaches; }
/** * @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; }