/** * Loads stationIds in system. * * @param \iveeCore\SDE $sde the SDE object * * @return void */ protected function loadStations(SDE $sde) { $res = $sde->query("SELECT stationID\n FROM staStations\n WHERE solarSystemID = " . $this->id . " UNION DISTINCT\n SELECT facilityID as stationID\n FROM " . Config::getIveeDbName() . ".outposts\n WHERE solarSystemID = " . $this->id . ";"); while ($row = $res->fetch_assoc()) { $this->stationIds[] = $row['stationID']; } }
/** * Constructor. Use iveeCore\Station::getById() to instantiate Station objects instead. * * @param int $id of the Station * * @throws \iveeCore\Exceptions\StationIdNotFoundException if stationID is not found */ protected function __construct($id) { $this->id = (int) $id; $this->setExpiry(); $sdeClass = Config::getIveeClassName('SDE'); $sde = $sdeClass::instance(); //regular Stations and Outposts need to be treated differently if ($this->id >= 61000000) { $row = $sde->query("SELECT io.stationTypeID, ownerID as playerCorpID, solarSystemID, stationName as playerStationName,\n operationID, conquerable, reprocessingEfficiency\n FROM " . Config::getIveeDbName() . ".outposts as io\n JOIN staStationTypes as sst ON sst.stationTypeID = io.stationTypeID\n WHERE facilityID = " . $this->id . ';')->fetch_assoc(); } else { $row = $sde->query("SELECT sta.operationID, sta.stationTypeID, sta.corporationID, sta.solarSystemID, sta.stationName,\n io.stationName as playerStationName, sta.reprocessingEfficiency, reprocessingStationsTake,\n factionID, conquerable, io.ownerID as playerCorpID\n FROM staStations as sta\n JOIN crpNPCCorporations as corps ON corps.corporationID = sta.corporationID\n JOIN staStationTypes as sst ON sst.stationTypeID = sta.stationTypeID\n LEFT JOIN " . Config::getIveeDbName() . ".outposts as io ON io.facilityID = stationID\n WHERE stationID = " . $this->id . ';')->fetch_assoc(); } if (empty($row)) { static::throwException('StationIdNotFoundException', "Station ID=" . $this->id . " not found"); } //set data to attributes $this->conquerable = (bool) $row['conquerable']; $this->solarSystemId = (int) $row['solarSystemID']; $this->stationTypeId = (int) $row['stationTypeID']; $this->corporationId = ($this->conquerable and isset($row['playerCorpID'])) ? (int) $row['playerCorpID'] : (int) $row['corporationID']; $this->name = ($this->conquerable and isset($row['playerStationName'])) ? $row['playerStationName'] : $row['stationName']; $this->operationId = (int) $row['operationID']; $this->reprocessingEfficiency = (double) $row['reprocessingEfficiency']; if ($this->id < 61000000) { $this->factionId = (int) $row['factionID']; $this->reprocessingStationsTake = (double) $row['reprocessingStationsTake']; } if ($this->id >= 61000000) { $res = $sde->query("SELECT ritc.assemblyLineTypeID, activityID\n FROM ramInstallationTypeContents as ritc\n JOIN ramAssemblyLineTypes as ralt ON ritc.assemblyLineTypeID = ralt.assemblyLineTypeID\n WHERE installationTypeID = " . $this->stationTypeId . ';'); } else { //get assembly lines in station $res = $sde->query("SELECT rals.assemblyLineTypeID, ralt.activityID\n FROM ramAssemblyLineStations as rals\n JOIN ramAssemblyLineTypes as ralt ON ralt.assemblyLineTypeID = rals.assemblyLineTypeID\n WHERE stationID = " . $this->id . ';'); } while ($row = $res->fetch_assoc()) { $this->assemblyLineTypeIds[$row['activityID']][] = $row['assemblyLineTypeID']; } }