use data config file
This commit is contained in:
parent
842bb0eb40
commit
6cf4c83593
|
@ -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());
|
||||
|
|
Loading…
Reference in New Issue