diff options
Diffstat (limited to 'private/model/Connection.php')
| -rw-r--r-- | private/model/Connection.php | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/private/model/Connection.php b/private/model/Connection.php index 26632f7..31b58c3 100644 --- a/private/model/Connection.php +++ b/private/model/Connection.php @@ -1,5 +1,7 @@ <?php +declare(strict_types = On); + namespace AugustOffensive\model; /** @@ -7,6 +9,8 @@ namespace AugustOffensive\model; */ class Connection { + /** @var PDO $_conn PDO connection to database. */ + private $_conn; /** * Initiates connection to PostGreSQL database. * @@ -14,6 +18,23 @@ class Connection */ public function __construct () { - // + // Establish connection to db + include './creds.php'; + + try { + $_conn = new PDO( + "pgsql: host=" . $cred->getHost() . + (($cred->getPort() !== '') ? ";port=" . $cred->getPort() : '') . + ";dbname=" . $cred->getDBName(), + $cred->getLogin(), + $cred->getPassword() + ); + // we destroy $cred as quickly as possible + $cred = null; + } catch (PDOException as $e) { + // we destroy $cred as quickly as possible + $cred = null; + die(json_encode(array("Result-Type" => "Error", "Content" => array($e)))); + } } } |
