Skip to content

Commit

Permalink
Implement SectorGateway
Browse files Browse the repository at this point in the history
  • Loading branch information
thekabal committed Mar 12, 2018
1 parent 2efd087 commit 3ad3a78
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 23 deletions.
7 changes: 2 additions & 5 deletions beacon.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,8 @@
$playerinfo = $players_gateway->selectPlayerInfo($_SESSION['username']);

// Get sectorinfo from database
$sql = "SELECT * FROM ::prefix::universe WHERE sector_id=:sector_id LIMIT 1";
$stmt = $pdo_db->prepare($sql);
$stmt->bindParam(':sector_id', $playerinfo['sector'], PDO::PARAM_INT);
$stmt->execute();
$sectorinfo = $stmt->fetch(PDO::FETCH_ASSOC);
$sectors_gateway = new \Tki\Sectors\SectorsGateway($pdo_db); // Build a sector gateway object to handle the SQL calls
$sectorinfo = $sectors_gateway->selectSectorInfo($playerinfo['sector']);

$allowed_rsw = "N";

Expand Down
7 changes: 2 additions & 5 deletions check_fighters.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,8 @@
$langvars = Tki\Translate::load($pdo_db, $lang, array('check_fighters', 'common', 'global_includes', 'global_funcs', 'combat', 'footer', 'news', 'regional'));

// Get sectorinfo from database
$sql = "SELECT * FROM ::prefix::universe WHERE sector_id=:sector_id LIMIT 1";
$stmt = $pdo_db->prepare($sql);
$stmt->bindParam(':sector_id', $sector, PDO::PARAM_INT);
$stmt->execute();
$sectorinfo = $stmt->fetch(PDO::FETCH_ASSOC);
$sectors_gateway = new \Tki\Sectors\SectorsGateway($pdo_db); // Build a sector gateway object to handle the SQL calls
$sectorinfo = $sectors_gateway->selectSectorInfo($sector);

$result3 = $db->Execute("SELECT * FROM {$db->prefix}sector_defense WHERE sector_id = ? and defense_type ='F' ORDER BY quantity DESC;", array($sector));
Tki\Db::logDbErrors($pdo_db, $result3, __LINE__, __FILE__);
Expand Down
7 changes: 2 additions & 5 deletions check_mines.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,8 @@
$langvars = Tki\Translate::load($pdo_db, $lang, array('check_mines', 'common', 'global_includes', 'combat', 'footer', 'news'));

// Get sectorinfo from database
$sql = "SELECT * FROM ::prefix::universe WHERE sector_id=:sector_id LIMIT 1";
$stmt = $pdo_db->prepare($sql);
$stmt->bindParam(':sector_id', $sector, PDO::PARAM_INT);
$stmt->execute();
$sectorinfo = $stmt->fetch(PDO::FETCH_ASSOC);
$sectors_gateway = new \Tki\Sectors\SectorsGateway($pdo_db); // Build a sector gateway object to handle the SQL calls
$sectorinfo = $sectors_gateway->selectSectorInfo($sector);

// Put the defense information into the array defenseinfo
$result3 = $db->Execute("SELECT * FROM {$db->prefix}sector_defense WHERE sector_id = ? and defense_type ='M'", array($sector));
Expand Down
9 changes: 3 additions & 6 deletions lrscan.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,9 @@
$row2 = $result2->fields;
$num_ships = $row2['count'];

// Get sectorinfo from database
$sql = "SELECT * FROM ::prefix::universe WHERE sector_id=:sector_id LIMIT 1";
$stmt = $pdo_db->prepare($sql);
$stmt->bindParam(':sector_id', $row['link_dest'], PDO::PARAM_INT);
$stmt->execute();
$sectorinfo = $stmt->fetch(PDO::FETCH_ASSOC);
// Pull sector info from database
$sectors_gateway = new \Tki\Sectors\SectorsGateway($pdo_db); // Build a sector gateway object to handle the SQL calls
$sectorinfo = $sectors_gateway->selectSectorInfo($row['link_dest']);

// Get port type and discover the presence of a planet in scanned sector
$result3 = $db->Execute("SELECT planet_id FROM {$db->prefix}planets WHERE sector_id = ?;", array($row['link_dest']));
Expand Down
3 changes: 1 addition & 2 deletions main.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@
die();
}


// Pull sector info from database
$sectors_gateway = new \Tki\Sectors\SectorsGateway($pdo_db); // Build a sector gateway object to handle the SQL calls
$sectorinfo = $sectors_gateway->selectsectorInfo($playerinfo['sector']);
$sectorinfo = $sectors_gateway->selectSectorInfo($playerinfo['sector']);

if ($playerinfo['on_planet'] == "Y")
{
Expand Down

0 comments on commit 3ad3a78

Please sign in to comment.