From: Devops Date: Mon, 29 May 2017 17:31:16 +0000 (+0100) Subject: minors X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=b5d845baffbcf8ed5e37667d3484dc71e8d73309;p=nb.git minors --- diff --git a/lib/php/db.php b/lib/php/db.php index 48a23109..488a24ca 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -1170,6 +1170,7 @@ class Db extends nb { $this->databases = []; $name = self::p('name',''); + if ($sql = $this->conf_type('databases') and !empty($this->conn)) { $fct = ''; if (is_array($sql)) list($sql,$fct) = count($sql)>1 ? $sql : [$sql[0],'']; diff --git a/lib/php/db/types/sqlite.php b/lib/php/db/types/sqlite.php index 74be8834..c54b69c4 100644 --- a/lib/php/db/types/sqlite.php +++ b/lib/php/db/types/sqlite.php @@ -127,16 +127,21 @@ $DB_TYPES['sqlite'] = array ( return $sql; }, 'connect' => function($Db) { + if (!empty($Db->attach)) { + foreach ($Db->attach as $name => $file) { - try { - $Db->conn->exec("ATTACH DATABASE '$file' as $name"); - } catch (PDOException $e) { - if (!strpos($e->getMessage(),'database sys is already in use')) { - err($e->getMessage()); + + try { + $Db->conn->exec("ATTACH DATABASE '$file' as $name"); + } catch (PDOException $e) { + if (!strpos($e->getMessage(),'database sys is already in use')) { + err($e->getMessage()); + } } + } - } + } }, 'disconnect' => function($Db) {