From: Nicolas Boisselier Date: Tue, 6 Sep 2016 13:40:11 +0000 (+0200) Subject: sqlite attach no more db preff X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=f02abf3d044834fc41ef05ffb69ec8ff7dccd62a;p=nb.git sqlite attach no more db preff --- diff --git a/lib/php/db.php b/lib/php/db.php index b8d7620c..7ca9a620 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -378,7 +378,7 @@ class Db extends nb { foreach ($this->conn->query($sql,PDO::FETCH_ASSOC) as $row) { #debug($row); $name = current($row); - $this->table($name,$row); + $t = $this->table($name,$row); } } diff --git a/lib/php/db/types/sqlite.php b/lib/php/db/types/sqlite.php index 811cdc77..fc115433 100644 --- a/lib/php/db/types/sqlite.php +++ b/lib/php/db/types/sqlite.php @@ -70,19 +70,22 @@ $DB_TYPES['sqlite'] = array ( # NB 03.09.16 # Handle attach mechnisum #$Db->tables(); + static $sql; + if (isset($sql)) return $sql; $dbs = $Db->databases(); $debug = 0;#$Db->p('db')=='all'; + $sql = "SELECT name,type FROM (SELECT * FROM sqlite_master UNION ALL SELECT * FROM sqlite_temp_master) WHERE type IN('table','view') AND name NOT LIKE 'sqlite_%'"; if (count($dbs)<2) { - return "SELECT name,type FROM (SELECT * FROM sqlite_master UNION ALL SELECT * FROM sqlite_temp_master) WHERE type IN('table','view') AND name NOT LIKE 'sqlite_%'"; + return $sql; } if ($debug) debug($dbs); $sql = ''; foreach ($dbs as $db) { $sql .= ($sql ? ' UNION ' : '').str_replace('sqlite_',$db['name'].'.sqlite_', - #"SELECT name as name,type FROM sqlite_master WHERE type IN('table','view') AND name NOT LIKE 'sqlite_%'" - "SELECT '".$db['name'].".'||name as name,type FROM sqlite_master WHERE type IN('table','view') AND name NOT LIKE 'sqlite_%'" + #"SELECT '".$db['name'].".'||name as name,type FROM sqlite_master WHERE type IN('table','view') AND name NOT LIKE 'sqlite_%'" + "SELECT name,type FROM sqlite_master WHERE type IN('table','view') AND name NOT LIKE 'sqlite_%'" ); } if ($debug) debug($sql);