Browse Source

Support for resolving flags

master
Chris Smith 13 years ago
parent
commit
0de762ae95
2 changed files with 24 additions and 1 deletions
  1. 23
    0
      db/evedb.class.php
  2. 1
    1
      www/test.php

+ 23
- 0
db/evedb.class.php View File

@@ -14,6 +14,7 @@ class EveDB {
14 14
   $this->handlers = array(
15 15
    'items' => new ItemsTableHandler($this->pdo),
16 16
    'locations' => new LocationsTableHandler($this->pdo),
17
+   'flags' => new FlagsTableHandler($this->pdo),
17 18
   );
18 19
  }
19 20
 
@@ -55,6 +56,28 @@ class ItemsTableHandler extends BaseHandler {
55 56
 
56 57
 }
57 58
 
59
+class FlagsTableHandler extends BaseHandler {
60
+
61
+ private $getAllSmt;
62
+ private $cache = array();
63
+
64
+ protected function initStatements() {
65
+  $this->getAllSmt = $this->pdo->prepare('SELECT flagId AS id, flagName AS name, flagText AS text FROM invFlags');
66
+ }
67
+
68
+ public function getById($id) {
69
+  if (empty($this->cache)) {
70
+   $this->getAllSmt->execute();
71
+   foreach ($this->getAllSmt->fetchAll(PDO::FETCH_CLASS) as $flag) {
72
+    $this->cache[(int) $flag->id] = $flag;
73
+   }
74
+  }
75
+
76
+  return $this->cache[(int) $id];
77
+ }
78
+
79
+}
80
+
58 81
 class LocationsTableHandler extends BaseHandler {
59 82
 
60 83
  private $getByIdSmt;

+ 1
- 1
www/test.php View File

@@ -21,7 +21,7 @@
21 21
   }
22 22
 
23 23
   $res->quantity = $asset->quantity;
24
-  $res->flag = $asset->flag;
24
+  $res->flag = $db->flags->getById($asset->flag);
25 25
   $res->singleton = $asset->singleton;
26 26
   $res->item = $db->items->getById($asset->typeID);
27 27
   

Loading…
Cancel
Save