Db: add option to enable foreign keys support on SQLite backend
This commit is contained in:
parent
3b9bda3195
commit
da317d85d0
1 changed files with 10 additions and 0 deletions
10
src/Db.php
10
src/Db.php
|
@ -54,6 +54,7 @@ class Db {
|
|||
'datetime_format' => '%Y-%m-%d %H:%M:%S',
|
||||
'locale_time' => null,
|
||||
'auto_connect' => true,
|
||||
'sqlite_foreign_keys_support' => true,
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -87,6 +88,15 @@ class Db {
|
|||
static :: $fpdo -> debug = array(static :: class, 'debug_query');
|
||||
|
||||
Log :: trace("DB connection established (DSN: '%s')", $dsn);
|
||||
|
||||
// Enable SQLite foreign keys support
|
||||
if (
|
||||
self :: is_sqlite()
|
||||
&& App::get(static :: $config_prefix.".sqlite_foreign_keys_support")
|
||||
) {
|
||||
Log :: trace("Enable SQLite foreign keys support");
|
||||
self :: $pdo -> exec("PRAGMA foreign_keys = ON;");
|
||||
}
|
||||
}
|
||||
catch(Exception $e) {
|
||||
Log :: error("Fail to connect to DB (DSN : '%s') : %s", $dsn, $e->getMessage());
|
||||
|
|
Loading…
Reference in a new issue