Fixes db connection issues

main
Yasen Pramatarov 2025-04-14 18:07:15 +03:00
parent e96480807c
commit 45181c11c5
2 changed files with 10 additions and 2 deletions

View File

@ -18,8 +18,12 @@ class Log {
* @param object $database The database object to initialize the connection. * @param object $database The database object to initialize the connection.
*/ */
public function __construct($database) { public function __construct($database) {
if ($database instanceof PDO) {
$this->db = $database;
} else {
$this->db = $database->getConnection(); $this->db = $database->getConnection();
} }
}
/** /**
* Insert a log event into the database. * Insert a log event into the database.

View File

@ -23,7 +23,11 @@ class RateLimiter {
]; ];
public function __construct($database) { public function __construct($database) {
if ($database instanceof PDO) {
$this->db = $database;
} else {
$this->db = $database->getConnection(); $this->db = $database->getConnection();
}
$this->log = new Log($database); $this->log = new Log($database);
$this->createTablesIfNotExist(); $this->createTablesIfNotExist();
} }