diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2025-08-10 10:46:41 +0200 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2025-08-10 10:46:41 +0200 |
commit | c14579871fa1241713128a2d0d5514af004e3371 (patch) | |
tree | 6b28c42958650d94c9aa1947a0b5c32eb869d89f /src/DB.php |
initial commit
Diffstat (limited to 'src/DB.php')
-rw-r--r-- | src/DB.php | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/DB.php b/src/DB.php new file mode 100644 index 0000000..b536079 --- /dev/null +++ b/src/DB.php @@ -0,0 +1,22 @@ +<?php + +namespace App; + +class DB +{ + use Singleton; + + private \PDO $connection; + + public function __construct() + { + $driver = $_ENV['DB_DRIVER'] ?? 'pgsql'; + $host = $_ENV['DB_HOST'] ?? 'localhost'; + $port = $_ENV['DB_PORT'] ?? 5432; + $dbname = $_ENV['DB_NAME']; + $user = $_ENV['DB_USER']; + $password = $_ENV['DB_PASSWORD']; + + $this->connection = new \PDO("$driver:host=$host;port=$port;dbname=$dbname", $user, $password); + } +} |