From cbbfe45c1bd7e34729dcb21cc5a2464e224a9565 Mon Sep 17 00:00:00 2001 From: tracer Date: Sun, 23 Oct 2022 12:32:53 +0200 Subject: [PATCH] added a side note --- src/Service/DatabaseConnection.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/Service/DatabaseConnection.php b/src/Service/DatabaseConnection.php index 65db774..7077b4b 100644 --- a/src/Service/DatabaseConnection.php +++ b/src/Service/DatabaseConnection.php @@ -1,27 +1,35 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + */ namespace App\Service; use PDO; /** - * + * Take care of the PDO object. */ class DatabaseConnection { private PDO $dbConnection; + // Currently no prefixes are used, but could be easily added to config.json. const TABLE_PREFIX = ''; const TABLE_USERS = self::TABLE_PREFIX . "users"; const TABLE_ADDRESSES = self::TABLE_PREFIX . "addresses"; - public function __construct(private readonly Config $configController) + public function __construct(private readonly Config $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'); + $dbHost = $this->config->getConfig(configKey: 'dbHost'); + $dbPort = $this->config->getConfig(configKey: 'dbPort'); + $dbDatabase = $this->config->getConfig(configKey: 'dbDatabase'); + $dbUser = $this->config->getConfig(configKey: 'dbUser'); + $dbPassword = $this->config->getConfig(configKey: 'dbPassword'); $this->dbConnection = new PDO( dsn: "mysql:host=$dbHost;port=$dbPort;charset=utf8mb4;dbname=$dbDatabase",