@@ 28-66 (lines=39) @@ | ||
25 | /** |
|
26 | * {@inheritdoc} |
|
27 | */ |
|
28 | public function latest() |
|
29 | { |
|
30 | $stmt = $this->pdo->query(" |
|
31 | SELECT |
|
32 | id, |
|
33 | profile, |
|
34 | url, |
|
35 | SERVER, |
|
36 | GET, |
|
37 | ENV, |
|
38 | simple_url, |
|
39 | request_ts, |
|
40 | request_ts_micro, |
|
41 | request_date |
|
42 | FROM {$this->table} |
|
43 | ORDER BY request_date ASC |
|
44 | LIMIT 1 |
|
45 | "); |
|
46 | ||
47 | $row = $stmt->fetch(PDO::FETCH_ASSOC); |
|
48 | if (false === $row) { |
|
49 | throw new Exception('No profile available yet.'); |
|
50 | } |
|
51 | ||
52 | return new Xhgui_Profile([ |
|
53 | '_id' => $row['id'], |
|
54 | 'meta' => [ |
|
55 | 'url' => $row['url'], |
|
56 | 'SERVER' => json_decode($row['SERVER'], true), |
|
57 | 'get' => json_decode($row['GET'], true), |
|
58 | 'env' => json_decode($row['ENV'], true), |
|
59 | 'simple_url' => $row['simple_url'], |
|
60 | 'request_ts' => (int) $row['request_ts'], |
|
61 | 'request_ts_micro' => $row['request_ts_micro'], |
|
62 | 'request_date' => $row['request_date'], |
|
63 | ], |
|
64 | 'profile' => json_decode($row['profile'], true) |
|
65 | ]); |
|
66 | } |
|
67 | ||
68 | /** |
|
69 | * {@inheritdoc} |
|
@@ 79-116 (lines=38) @@ | ||
76 | /** |
|
77 | * {@inheritdoc} |
|
78 | */ |
|
79 | public function get($id) |
|
80 | { |
|
81 | $stmt = $this->pdo->prepare(" |
|
82 | SELECT |
|
83 | profile, |
|
84 | url, |
|
85 | SERVER, |
|
86 | GET, |
|
87 | ENV, |
|
88 | simple_url, |
|
89 | request_ts, |
|
90 | request_ts_micro, |
|
91 | request_date |
|
92 | FROM {$this->table} |
|
93 | WHERE id = :id |
|
94 | "); |
|
95 | ||
96 | $stmt->execute(['id' => $id]); |
|
97 | ||
98 | if (false === $row = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
99 | throw new Exception('No profile data found.'); |
|
100 | } |
|
101 | ||
102 | return new Xhgui_Profile([ |
|
103 | '_id' => $id, |
|
104 | 'meta' => [ |
|
105 | 'url' => $row['url'], |
|
106 | 'SERVER' => json_decode($row['SERVER'], true), |
|
107 | 'get' => json_decode($row['GET'], true), |
|
108 | 'env' => json_decode($row['ENV'], true), |
|
109 | 'simple_url' => $row['simple_url'], |
|
110 | 'request_ts' => (int) $row['request_ts'], |
|
111 | 'request_ts_micro' => $row['request_ts_micro'], |
|
112 | 'request_date' => $row['request_date'], |
|
113 | ], |
|
114 | 'profile' => json_decode($row['profile'], true) |
|
115 | ]); |
|
116 | } |
|
117 | ||
118 | /** |
|
119 | * {@inheritdoc} |