Update Admin\Install page

Set journal_mode=WAL by default for SQLite.
This commit is contained in:
Visman 2021-12-17 16:02:17 +07:00
parent c0be6d857d
commit ef78e141ba
2 changed files with 16 additions and 1 deletions

View file

@ -82,6 +82,14 @@ class DB extends PDO
$this->dbType = $type;
$this->dbPrefix = $prefix;
if (isset($options['initSQLCommands'])) {
$initSQLCommands = implode(';', $options['initSQLCommands']);
unset($options['initSQLCommands']);
} else {
$initSQLCommands = null;
}
$options += [
self::ATTR_DEFAULT_FETCH_MODE => self::FETCH_ASSOC,
self::ATTR_EMULATE_PREPARES => false,
@ -96,6 +104,10 @@ class DB extends PDO
$this->saveQuery('PDO::__construct()', \microtime(true) - $start, false);
if ($initSQLCommands) {
$this->exec($initSQLCommands);
}
$this->beginTransaction();
}

View file

@ -506,9 +506,12 @@ class Install extends Admin
break;
case 'sqlite':
$this->c->DB_DSN = "sqlite:!PATH!{$dbname}";
$this->c->DB_OPTS_AS_STR = '\\PDO::ATTR_TIMEOUT => 5,';
$this->c->DB_OPTS_AS_STR = '\\PDO::ATTR_TIMEOUT => 5, \'initSQLCommands\' => [\'PRAGMA journal_mode=WAL\',],';
$this->c->DB_OPTIONS = [
PDO::ATTR_TIMEOUT => 5,
'initSQLCommands' => [
'PRAGMA journal_mode=WAL',
],
];
break;