From f0b67a0529dd833f502a084afd1beb183b6e2bf1 Mon Sep 17 00:00:00 2001 From: grandeljay Date: Mon, 25 Sep 2023 12:14:42 +0200 Subject: [PATCH] refactor: add database `connect` method --- index.php | 1 + src/classes/wishthis/Database.php | 4 ++++ src/pages/install.php | 1 + 3 files changed, 6 insertions(+) diff --git a/index.php b/index.php index 79b81a5c..a40a8dc7 100644 --- a/index.php +++ b/index.php @@ -72,6 +72,7 @@ if ( DATABASE_USER, DATABASE_PASSWORD ); + $database->connect(); /** * Options diff --git a/src/classes/wishthis/Database.php b/src/classes/wishthis/Database.php index f14eb5c4..9681b8c7 100644 --- a/src/classes/wishthis/Database.php +++ b/src/classes/wishthis/Database.php @@ -28,6 +28,10 @@ class Database public string $user, public string $password, ) { + } + + public function connect(): void + { $dsn = 'mysql:host=' . $this->host . ';dbname=' . $this->database . ';port=3306;charset=utf8'; $options = array('placeholders' => array()); diff --git a/src/pages/install.php b/src/pages/install.php index fa1be622..32a4e204 100644 --- a/src/pages/install.php +++ b/src/pages/install.php @@ -256,6 +256,7 @@ switch ($step) { $_SESSION['DATABASE_USER'], $_SESSION['DATABASE_PASSWORD'] ); + $database->connect(); unset($_SESSION); $database->query('SET foreign_key_checks = 0;');