Просмотр исходного кода

Support for resolving flags

master
Chris Smith 13 лет назад
Родитель
Сommit
0de762ae95
2 измененных файлов: 24 добавлений и 1 удалений
  1. 23
    0
      db/evedb.class.php
  2. 1
    1
      www/test.php

+ 23
- 0
db/evedb.class.php Просмотреть файл

14
   $this->handlers = array(
14
   $this->handlers = array(
15
    'items' => new ItemsTableHandler($this->pdo),
15
    'items' => new ItemsTableHandler($this->pdo),
16
    'locations' => new LocationsTableHandler($this->pdo),
16
    'locations' => new LocationsTableHandler($this->pdo),
17
+   'flags' => new FlagsTableHandler($this->pdo),
17
   );
18
   );
18
  }
19
  }
19
 
20
 
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
 class LocationsTableHandler extends BaseHandler {
81
 class LocationsTableHandler extends BaseHandler {
59
 
82
 
60
  private $getByIdSmt;
83
  private $getByIdSmt;

+ 1
- 1
www/test.php Просмотреть файл

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

Загрузка…
Отмена
Сохранить