diff --git a/Source/API/script/Config/ConnectClass.php b/Source/API/script/Config/ConnectClass.php new file mode 100644 index 0000000..f1865f7 --- /dev/null +++ b/Source/API/script/Config/ConnectClass.php @@ -0,0 +1,34 @@ +dsn = "mysql:host=".$_ENV["HOST"].";dbname=".$_ENV["DATABASE"].";"; + $this->login = $_ENV["USER"]; + $this->password = $_ENV["PASSWORD"]; + } + + function connect(): int|Connection + { + try { + + $connection = new Connection($this->dsn,$this->login,$this->password); + + }catch (PDOException){ + throw new PDOException(); + } + return $connection; + } + + +} diff --git a/Source/API/script/Config/config.php b/Source/API/script/Config/config.php deleted file mode 100644 index 6c17b53..0000000 --- a/Source/API/script/Config/config.php +++ /dev/null @@ -1,29 +0,0 @@ -connection = (new \Config\ConnectClass)->connect(); + $this->connection = (new ConnectClass)->connect(); }catch(PDOException $e){ throw new PDOException(); }