]> git.nbdom.net Git - nb.git/commitdiff
Bed
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 19 Sep 2016 23:41:42 +0000 (00:41 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 19 Sep 2016 23:41:42 +0000 (00:41 +0100)
lib/php/db/types/sqlite.php

index ef9f25bc230c46c6b28fdc6d821e28f830578ea5..20d4838da9311d7d8283851db992189291964b12 100644 (file)
@@ -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',