From d1325202eed992c9a139c2aebb8ef2b302a17426 Mon Sep 17 00:00:00 2001 From: tracer Date: Sat, 17 Sep 2022 16:26:14 +0200 Subject: [PATCH] introduced configcontroller --- src/Controller/DatabaseConnection.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Controller/DatabaseConnection.php b/src/Controller/DatabaseConnection.php index 52488de..fc7cbfc 100644 --- a/src/Controller/DatabaseConnection.php +++ b/src/Controller/DatabaseConnection.php @@ -1,4 +1,5 @@ config); + $dbHost = $this->configController->getConfig(configKey: 'dbHost'); + $dbPort = $this->configController->getConfig(configKey: 'dbPort'); + $dbDatabase = $this->configController->getConfig(configKey: 'dbDatabase'); + $dbUser = $this->configController->getConfig(configKey: 'dbUser'); + $dbPassword = $this->configController->getConfig(configKey: 'dbPassword'); + // TODO create config => encryption key try { $this->dbConnection = new PDO( - dsn: "mysql:host=$dbHost;port=$dbPort;charset=utf8mb4;dbname=$dbDatabase", + dsn : "mysql:host=$dbHost;port=$dbPort;charset=utf8mb4;dbname=$dbDatabase", username: $dbUser, password: $dbPassword ); @@ -101,7 +107,7 @@ class DatabaseConnection } exit(1); } - + } catch (PDOException $exception) { echo $exception->getMessage() . PHP_EOL; echo 'Did you create the database and adjust the config file?' . PHP_EOL;