summaryrefslogtreecommitdiff
path: root/src/DB.php
blob: 53d078b76a3df973bd7a992015e9c73fb0b75e0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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);
  }
}