summaryrefslogtreecommitdiff
path: root/src/DB.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/DB.php')
-rw-r--r--src/DB.php22
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);
+ }
+}