]> git.nbdom.net Git - nb.git/commitdiff
etc/dbq/zz-sqlite.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 24 Oct 2017 10:28:00 +0000 (11:28 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 24 Oct 2017 10:28:00 +0000 (11:28 +0100)
etc/dbq.php
etc/dbq/000-local.php
etc/dbq/zz-sqlite.php

index be99660aaf90c537e6042c2a936e58f631afa300..48ec9b894fbe37f55a7aab28c3c2ea50943a63af 100644 (file)
@@ -1,30 +1,8 @@
 <?php
-#require_once dirname(__FILE__).'/../lib/php/nb.php';
 require_once dirname(__FILE__).'/../lib/php/db.php';
 #
 # Globals
 #
 $DBQ = [];
 
-# DIR_SQLITE=*/var/lib/sqlite
-unset($DIR_SQLITE);
-foreach ([
-  '/home/nico/ownCloud',
-  '/Users/nico/ownCloud',
-  '/home/nico/Dropbox',
-  '/Users/nico/Dropbox',
-  '', # / !!!
-] as $DIR_SQLITE) {
-
-  if (is_readable($DIR_SQLITE.'/var/lib/sqlite')) {
-    $DIR_SQLITE .= '/var/lib/sqlite';
-    break;
-
-  } else {
-    unset($DIR_SQLITE);
-
-  }
-
-}
-
 ?>
index 71b99f8d69cf14e8dafd5e2f9c9ebd4875efd741..d7c24a7592a5fa1353cfbfbf3e0aa1ccc1d00a74 100644 (file)
@@ -2,14 +2,7 @@
 #
 # !!! MANDATORY !!!
 #
-# NB 12.12.16 if (true or !nb::is_vm())
 $DBQ = [
-# NB 29.11.16   'shell' => [
-# NB 29.11.16     'type' => 'sqlite',
-# NB 29.11.16     'name' => 'shell',
-# NB 29.11.16     'default_table' => 'shell_function',
-# NB 29.11.16     'host' => nb::ROOT_DIR.'/share/db/shell.db',
-# NB 29.11.16   ],
   'nb-sys' => [
     'type' => 'sqlite',
     'name' => 'Sys',
index a1bdc74465b1e7c12454bcdbd3c3d63aef7e2374..cec1d33ea716d151b8f1085123d0b548df616626 100644 (file)
@@ -2,35 +2,48 @@
 #
 # Create *-sqlite databases
 #
-if (empty($DIR_SQLITE)) return;
-
 $host_already_exists = [];
-foreach ($DBQ as $id => $db) {
-  if (1
-    and !empty($db['type']) and $db['type'] == 'sqlite'
-    and !empty($db['host']) 
-  ) $host_already_exists[$db['host']] = $id;
-}
 
-foreach (nb::ls_dir($DIR_SQLITE,'\.db$') as $file) {
+foreach ([
+  '/home/nico/ownCloud',
+  '/Users/nico/ownCloud',
+  '/home/nico/Dropbox',
+  '/Users/nico/Dropbox',
+  '', # / !!!
+] as $DIR_SQLITE) {
+  if (!is_readable($DIR_SQLITE.'/var/lib/sqlite')) continue;
+  $DIR_SQLITE .= '/var/lib/sqlite';
+
+  foreach ($DBQ as $id => $db) {
+    if (1
+      and !empty($db['type']) and $db['type'] == 'sqlite'
+      and !empty($db['host']) 
+    ) $host_already_exists[$db['host']] = $id;
+  }
+
+  foreach (nb::ls_dir($DIR_SQLITE,'\.db$') as $file) {
+
+    if (strpos($file,'_conflict-')) continue;
 
-  if (strpos($file,'_conflict-')) continue;
+    if (isset($host_already_exists["$DIR_SQLITE/$file"])) {
+      $DBQ[$host_already_exists["$DIR_SQLITE/$file"]]['sql_pre'][] = 'PRAGMA journal_mode=OFF';
+      continue;
+    }
 
-  if (isset($host_already_exists["$DIR_SQLITE/$file"])) {
-    $DBQ[$host_already_exists["$DIR_SQLITE/$file"]]['sql_pre'][] = 'PRAGMA journal_mode=OFF';
-    continue;
+    $name = basename($file,'.db');
+    $id = "${name}-sqlite";
+
+    if (!isset($DBQ[$id])) $DBQ[$id] = [
+      'host' => "$DIR_SQLITE/$file",
+      'type' => 'sqlite',
+      #'title' => 'created by dbq.php',
+      'title' => Db::prettyText($name),
+      '_import' => $name
+    ];
+    #if (!empty($DBQ[$name])) $DBQ[$id] = array_merge_recursive($DBQ[$name],$DBQ[$id]);
   }
 
-  $name = basename($file,'.db');
-  $id = "${name}-sqlite";
-
-  if (!isset($DBQ[$id])) $DBQ[$id] = [
-    'host' => "$DIR_SQLITE/$file",
-    'type' => 'sqlite',
-    #'title' => 'created by dbq.php',
-    'title' => Db::prettyText($name),
-    '_import' => $name
-  ];
-  #if (!empty($DBQ[$name])) $DBQ[$id] = array_merge_recursive($DBQ[$name],$DBQ[$id]);
 }
+
+unset($DIR_SQLITE,$host_already_exists);
 ?>