diff --git a/models/Database.php b/models/Database.php index 66363b3c..c8e2e028 100644 --- a/models/Database.php +++ b/models/Database.php @@ -28,17 +28,17 @@ class Database */ public function __construct($server, $user, $password, $name) { - $this->connection = @mysqli_connect($server, $user, $password, $name); - - // Give up if we have a connection error. - if (mysqli_connect_error()) + try { - header('HTTP/1.1 503 Service Temporarily Unavailable'); + $this->connection = new mysqli($server, $user, $password, $name); + $this->connection->set_charset('utf8mb4'); + } + catch (mysqli_sql_exception $e) + { + http_response_code(503); echo '
Our software could not connect to the database. We apologise for any inconvenience and ask you to check back later.
'; exit; } - - $this->query('SET NAMES {string:utf8mb4}', ['utf8mb4' => 'utf8mb4']); } public function getQueryCount()