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; private PDO $dbConnection;
public function __construct() public function __construct(private array $config)
{ {
// get from config later extract($this->config);
$dbHost = "localhost";
$dbPort = 3306;
$dbDatabase = "tfunix_db1";
$dbUser = "tfunix_db1";
$dbPassword = "aWeirder1";
try { try {
$this->dbConnection = new PDO( $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, username: $dbUser,
password: $dbPassword password: $dbPassword
); );
} catch (PDOException $exception) { } catch (PDOException $exception) {
exit($exception->getMessage()); exit($exception->getMessage());