Explorar o código

Update Admin\Install page

Set journal_mode=WAL by default for SQLite.
Visman %!s(int64=3) %!d(string=hai) anos
pai
achega
ef78e141ba
Modificáronse 2 ficheiros con 16 adicións e 1 borrados
  1. 12 0
      app/Core/DB.php
  2. 4 1
      app/Models/Pages/Admin/Install.php

+ 12 - 0
app/Core/DB.php

@@ -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();
     }
 

+ 4 - 1
app/Models/Pages/Admin/Install.php

@@ -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;