use data config file

This commit is contained in:
tracer 2022-01-22 14:27:09 +01:00
parent 842bb0eb40
commit 6cf4c83593
1 changed files with 2 additions and 8 deletions

View File

@ -12,21 +12,15 @@ class DatabaseConnection
{
private PDO $dbConnection;
public function __construct()
public function __construct(private array $config)
{
// get from config later
$dbHost = "localhost";
$dbPort = 3306;
$dbDatabase = "tfunix_db1";
$dbUser = "tfunix_db1";
$dbPassword = "aWeirder1";
extract($this->config);
try {
$this->dbConnection = new PDO(
dsn: "mysql:host=$dbHost;port=$dbPort;charset=utf8mb4;dbname=$dbDatabase",
username: $dbUser,
password: $dbPassword
);
} catch (PDOException $exception) {
exit($exception->getMessage());