diff options
author | Andrew Dolgov <[email protected]> | 2021-03-14 14:17:18 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2021-03-14 14:17:18 +0300 |
commit | 1c9afba5f058adace5e005b51fc533882f9af0fa (patch) | |
tree | 99f4a228acf9f969d5411048c210338ba0fd126a /classes | |
parent | 2b8b845abe7c13ecbb266613910484310cffe8e1 (diff) |
* add CSRF protection to xhr requests
* force ORM to use SQLITE WAL
* add .editorconfig
* cleanup a few things
Diffstat (limited to 'classes')
-rw-r--r-- | classes/db.php | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/classes/db.php b/classes/db.php index cc835b7..61467eb 100644 --- a/classes/db.php +++ b/classes/db.php @@ -7,14 +7,21 @@ class Db { try { $this->pdo = new PDO(self::get_dsn()); } catch (Exception $e) { - die("Unable to initialize database driver (SQLite): $e"); + user_error($e, E_USER_WARNING); + die("Unable to initialize database driver (SQLite)."); } //$this->dbh->busyTimeout(30*1000); $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - $this->pdo->query('PRAGMA journal_mode = wal;'); + $this->pdo->query('PRAGMA journal_mode = wal'); - ORM::configure(self::get_dsn()); - ORM::configure('return_result_sets', true); + try { + ORM::configure(self::get_dsn()); + ORM::configure('return_result_sets', true); + ORM::raw_execute('PRAGMA journal_mode = wal'); + } catch (Exception $e) { + user_error($e, E_USER_WARNING); + die("Unable to initialize ORM layer."); + } } public static function get_dsn() { |