From 45181c11c51ba9180596cd2c0727ca80d0b25e5f Mon Sep 17 00:00:00 2001 From: Yasen Pramatarov Date: Mon, 14 Apr 2025 18:07:15 +0300 Subject: [PATCH] Fixes db connection issues --- app/classes/log.php | 6 +++++- app/classes/ratelimiter.php | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/classes/log.php b/app/classes/log.php index 03ae1d5..7d41af4 100644 --- a/app/classes/log.php +++ b/app/classes/log.php @@ -18,7 +18,11 @@ class Log { * @param object $database The database object to initialize the connection. */ public function __construct($database) { - $this->db = $database->getConnection(); + if ($database instanceof PDO) { + $this->db = $database; + } else { + $this->db = $database->getConnection(); + } } /** diff --git a/app/classes/ratelimiter.php b/app/classes/ratelimiter.php index 5ee17af..04d4a09 100644 --- a/app/classes/ratelimiter.php +++ b/app/classes/ratelimiter.php @@ -23,7 +23,11 @@ class RateLimiter { ]; public function __construct($database) { - $this->db = $database->getConnection(); + if ($database instanceof PDO) { + $this->db = $database; + } else { + $this->db = $database->getConnection(); + } $this->log = new Log($database); $this->createTablesIfNotExist(); }