From: Nicolas Boisselier Date: Mon, 19 Sep 2016 23:41:42 +0000 (+0100) Subject: Bed X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=5cf65d4c0bd6faf5c5b5501aed659b6af81e0adc;p=nb.git Bed --- diff --git a/lib/php/db/types/sqlite.php b/lib/php/db/types/sqlite.php index ef9f25bc..20d4838d 100644 --- a/lib/php/db/types/sqlite.php +++ b/lib/php/db/types/sqlite.php @@ -57,30 +57,24 @@ $DB_TYPES['sqlite'] = array ( '_tables' => "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_%'", 'tables' => function($Db) { - # 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'; +# NB 20.09.16: There is a bug about wrong type: `dbq out=human a=tables name=oc_contact` + static $sql; if (isset($sql)) return $sql; $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 $sql; - } + $dbs = $Db->databases(); + if (count($dbs)<2) return $sql; - if ($debug) debug($dbs); - $sql = ''; + # Handle attach mechnisum + $all = ''; + $all = 'SELECT name,type,"main" as database FROM sqlite_temp_master'; foreach ($dbs as $db) { - $sql .= ($sql ? ' UNION ' : '').str_replace('sqlite_',$db['name'].'.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_%'" + $all .= ($all ? ' UNION ' : '').str_replace('sqlite_master',$db['name'].'.sqlite_master', + "SELECT name,type,'".$db['name']."' as database FROM sqlite_master WHERE type IN('table','view') AND name NOT LIKE 'sqlite_%'" ); + #bye($all); } - if ($debug) debug($sql); - return $sql; + return $all; }, #'tables' => '.tables',