| @@ 28-55 (lines=28) @@ | ||
| 25 | $this->initSchema(); |
|
| 26 | } |
|
| 27 | ||
| 28 | public function getLatest(): array |
|
| 29 | { |
|
| 30 | $query = sprintf(' |
|
| 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 %s |
|
| 43 | ORDER BY "request_date" ASC |
|
| 44 | LIMIT 1', |
|
| 45 | $this->table |
|
| 46 | ); |
|
| 47 | $stmt = $this->pdo->query($query); |
|
| 48 | ||
| 49 | $row = $stmt->fetch(PDO::FETCH_ASSOC); |
|
| 50 | if ($row === false) { |
|
| 51 | throw new RuntimeException('No profile available yet.'); |
|
| 52 | } |
|
| 53 | ||
| 54 | return $row; |
|
| 55 | } |
|
| 56 | ||
| 57 | public function getById(string $id): array |
|
| 58 | { |
|
| @@ 57-82 (lines=26) @@ | ||
| 54 | return $row; |
|
| 55 | } |
|
| 56 | ||
| 57 | public function getById(string $id): array |
|
| 58 | { |
|
| 59 | $query = sprintf(' |
|
| 60 | SELECT |
|
| 61 | "profile", |
|
| 62 | "url", |
|
| 63 | "SERVER", |
|
| 64 | "GET", |
|
| 65 | "ENV", |
|
| 66 | "simple_url", |
|
| 67 | "request_ts", |
|
| 68 | "request_ts_micro", |
|
| 69 | "request_date" |
|
| 70 | FROM %s |
|
| 71 | WHERE id = :id |
|
| 72 | ', $this->table); |
|
| 73 | $stmt = $this->pdo->prepare($query); |
|
| 74 | $stmt->execute(['id' => $id]); |
|
| 75 | ||
| 76 | $row = $stmt->fetch(PDO::FETCH_ASSOC); |
|
| 77 | if ($row === false) { |
|
| 78 | throw new RuntimeException('No profile data found.'); |
|
| 79 | } |
|
| 80 | ||
| 81 | return $row; |
|
| 82 | } |
|
| 83 | ||
| 84 | public function countByUrl(string $url): int |
|
| 85 | { |
|