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