prepare($sql); $stmt->execute(['api_key' => $apiKey]); $row = $stmt->fetch(); if (!$row) { return [ false, [ 'code' => 'API_KEY_NOT_FOUND', 'message' => 'Invalid API key' ] ]; } return [true, $row]; } catch (\Throwable $e) { return [ false, [ 'code' => 'AUTH_DB_ERROR', 'message' => 'Failed to query auth database' ] ]; } } public function touchLastUsed(string $apiKey): void { $sql = "UPDATE api_keys SET last_used_at = datetime('now') WHERE api_key = :api_key"; try { AuthModelFactory::db() ->prepare($sql) ->execute(['api_key' => $apiKey]); } catch (\Throwable $e) { // falha aqui NÃO bloqueia request } } }