summaryrefslogtreecommitdiff
path: root/frontend/conf.php
diff options
context:
space:
mode:
authorCamil Staps2017-02-07 17:49:10 +0100
committerCamil Staps2017-02-07 17:49:10 +0100
commitb46cee71f79795f7300c275f2cfea7fca27a752d (patch)
treeb5cb3efe092ba606ddfd6b90c16f144c219d74c7 /frontend/conf.php
parentDockerise (diff)
Web interface
Diffstat (limited to 'frontend/conf.php')
-rw-r--r--frontend/conf.php20
1 files changed, 17 insertions, 3 deletions
diff --git a/frontend/conf.php b/frontend/conf.php
index f47a7cb..dea8c25 100644
--- a/frontend/conf.php
+++ b/frontend/conf.php
@@ -3,7 +3,21 @@ define('DB_HOST', 'db');
define('DB_NAME', 'clpmdb');
define('DB_USER', 'clpm');
define('DB_PASS', 'clpm');
+define('DB_PORT', 3306);
-$db = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
-if (mysqli_connect_errno())
- die('Connection to the database failed.');
+session_start();
+
+try {
+ $_pdo = new PDO("mysql:host=".DB_HOST.";port=".DB_PORT.";dbname=".DB_NAME.";charset=utf8", DB_USER, DB_PASS);
+ $_pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+ $_pdo->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_NATURAL);
+ $_pdo->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
+} catch (PDOException $e) {
+ die("Down until PDO error fixed.");
+}
+
+spl_autoload_register(function ($pClass) {
+ $path = __DIR__ . "/$pClass.php";
+ if (file_exists($path))
+ require_once($path);
+});