$apiKey, ':id' => $id, ]; $query = ( 'SELECT event_logbook.id, event_logbook.ip, event_logbook.raw, event_logbook.started, event_logbook.error_text, event_logbook.error_type, event_error_type.name AS error_name, event_error_type.value AS error_value FROM event_logbook LEFT JOIN event_error_type ON (event_logbook.error_type = event_error_type.id) WHERE event_logbook.id = :id AND event_logbook.key = :api_key LIMIT 1' ); $results = $this->execQuery($query, $params); return $results[0] ?? []; } public function rotateRequests(?int $apiKey): int { $params = [ ':key' => $apiKey, ':limit' => \Utils\Variables::getLogbookLimit(), ]; $query = ( 'SELECT id FROM event_logbook WHERE key = :key ORDER BY id DESC LIMIT 1 OFFSET :limit' ); $result = $this->execQuery($query, $params); if (!count($result)) { return 0; } $params = [ ':id' => $result[0]['id'], ':key' => $apiKey, ]; $query = ( 'DELETE FROM event_logbook WHERE id < :id AND key = :key' ); return $this->execQuery($query, $params); } }