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