diff options
Diffstat (limited to 'frontend/conf.php')
-rw-r--r-- | frontend/conf.php | 20 |
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); +}); |