Explorar el Código

Add support for resolving locations

master
Chris Smith hace 13 años
padre
commit
20644a226c
Se han modificado 2 ficheros con 34 adiciones y 2 borrados
  1. 32
    0
      db/evedb.class.php
  2. 2
    2
      www/test.php

+ 32
- 0
db/evedb.class.php Ver fichero

@@ -13,6 +13,7 @@ class EveDB {
13 13
 
14 14
   $this->handlers = array(
15 15
    'items' => new ItemsTableHandler($this->pdo),
16
+   'locations' => new LocationsTableHandler($this->pdo),
16 17
   );
17 18
  }
18 19
 
@@ -54,4 +55,35 @@ class ItemsTableHandler extends BaseHandler {
54 55
 
55 56
 }
56 57
 
58
+class LocationsTableHandler extends BaseHandler {
59
+
60
+ private $getByIdSmt;
61
+
62
+ protected function initStatements() {
63
+  $this->getByIdSmt = $this->pdo->prepare('SELECT categoryName, itemName FROM mapDenormalize JOIN invTypes ON (mapDenormalize.typeID = invTypes.typeID) JOIN invGroups ON (invGroups.groupID = invTypes.groupID) JOIN invCategories ON (invGroups.categoryID = invCategories.categoryID) WHERE itemID = :id');
64
+ }
65
+
66
+ public function getById($id) {
67
+  // 66014940 <= locationID <= 66014952 then staStations.stationID  = locationID - 6000000
68
+  // 66000000 <= locationID <= 66999999 then staStations.stationID  = locationID - 6000001
69
+  // 67000000 <= locationID <= 67999999 then ConqStations.stationID = locationID - 6000000
70
+  // 60014861 <= locationID <= 60014928 then ConqStations.stationID = locationID
71
+  // 60000000 <= locationID <= 61000000 then staStations.stationID  = locationID
72
+  // 61000000 <= locationID             then ConqStations.stationID = locationID
73
+  //                                 default mapDenormalize.itemID  = locationID
74
+
75
+  $id = (double) $id;
76
+
77
+  if (66014940 <= $id && $id <= 66014952 || 67000000 <= $id && $id <= 67999999) {
78
+   $id -= 6000000;
79
+  } else if (66000000 <= $id && $id <= 66999999) {
80
+   $id -= 6000001;
81
+  }
82
+
83
+  $this->getByIdSmt->execute(array(':id' => $id));
84
+  return $this->getByIdSmt->fetch(PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE);
85
+ }
86
+
87
+}
88
+
57 89
 ?>

+ 2
- 2
www/test.php Ver fichero

@@ -17,7 +17,7 @@
17 17
   $res->id = $asset->itemID;
18 18
 
19 19
   if (isset($asset->locationID)) {
20
-   $res->location = $asset->locationID;
20
+   $res->location = $db->locations->getById($asset->locationID);
21 21
   }
22 22
 
23 23
   $res->quantity = $asset->quantity;
@@ -36,7 +36,7 @@
36 36
   return $res;
37 37
  }
38 38
 
39
- foreach ($api->charScope->AssetList(array('characterID' => $_GET['char']))->assets as $asset) {
39
+ foreach ($api->corpScope->AssetList(array('characterID' => $_GET['char']))->assets as $asset) {
40 40
   var_dump(getAsset($asset));
41 41
  }
42 42
 ?>

Loading…
Cancelar
Guardar