'_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',