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