]> git.nbdom.net Git - nb.git/commitdiff
Bed
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 12 Aug 2016 00:13:47 +0000 (02:13 +0200)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 12 Aug 2016 00:13:47 +0000 (02:13 +0200)
bin/dbq
bin/dbq-shell
lib/php/db.php
lib/php/db/index.php
lib/php/nb.php

diff --git a/bin/dbq b/bin/dbq
index bc939a24c2032dcfa139c107194dcf3c8e4fa2b6..eed0143894114cdfa900c01631a57cf08a63a504 100755 (executable)
--- a/bin/dbq
+++ b/bin/dbq
@@ -44,6 +44,8 @@ my %CMD_ALIASE = (
 # NB 09.04.16   'd' => 'db',
 # NB 09.04.16   't' => 'table',
   'f' => 'format',
+  'o' => 'format',
+  'out' => 'format',
 # NB 09.04.16   'l' => 'limit',
 # NB 09.04.16   'a' => 'action',
 # NB 09.04.16   'h' => 'header',
index d251fcb420ccfb9cf82b7810ee74b0a01709abdf..30770d05dec9086ec40a313244c61bf708255a7a 100755 (executable)
@@ -1,5 +1,14 @@
 #!/usr/bin/env sh
-NAME="$(basename "${0}")"
+##############################################################################
+#
+# NB 12.08.16
+#
+# dbq-shell
+#
+# To use in /etc/passwd
+#
+##############################################################################
+#NAME="$(basename "${0}")"
 PATH="$PATH:$(cd "$(dirname "${0}")"; echo $(pwd))"
 while read line;
   do eval "dbq $line"
index 629419c9faffe1d9943a9bfdc7f0b28c477b93ff..a863fe077b501eb2604149e073f74de120395808 100644 (file)
@@ -458,7 +458,7 @@ class Db extends nb {
   * @param [FILES] $files Files to load
   * @return ARRAY the new/existing value of $this->db
   */
-  static function conf_dbs($files=array(),&$first=false) {
+  public static function conf_dbs($files=array(),&$first=false) {
     if (empty($files)) return array();
 
     # Load all files into a $h if #files is not a hash
@@ -841,6 +841,27 @@ return;
     return $this->databases;
   }
 
+  public static function pinit() {
+    Db::paliases(array(
+      'd' => 'db',
+      't' => 'table',
+      'f' => 'format',
+      'out' => 'format',
+      'l' => 'limit',
+      'a' => 'action',
+      'h' => 'header',
+    ));
+
+    #if($format = out::client_type()) Db::pset('format',$format);
+
+    # Param - Extract dbname from table
+    if (preg_match('/^(\w+)\.(.*?)$/',Db::p('table'),$m)) {
+      Db::pset('db',$m[1]);
+      Db::pset('table',$m[2]);
+    }
+
+  }
+
 } # < Class
 
 ?>
index ec9b0716f9a50e67ad3a37312970cd6b72024c19..30e832ed1e564e58681642372a50a729b4a84012 100755 (executable)
@@ -9,26 +9,10 @@
 require_once(realpath(dirname(__FILE__).'/../config.php'));
 require_once(realpath(dirname(__FILE__).'/../db.php'));
 
-Db::paliases(array(
-  'd' => 'db',
-  't' => 'table',
-  'f' => 'format',
-  'out' => 'format',
-  'l' => 'limit',
-  'a' => 'action',
-  'h' => 'header',
-));
-
+Db::pinit();
 # Set format from client Accept if != html
 #bye(out::client_type());
 Db::pdef('format',out::client_type());
-#if($format = out::client_type()) Db::pset('format',$format);
-
-# Param - Extract dbname from table
-if (preg_match('/^(\w+)\.(.*?)$/',Db::p('table'),$m)) {
-  Db::pset('db',$m[1]);
-  Db::pset('table',$m[2]);
-}
 
 if(defined('DB_NO_INIT') and DB_NO_INIT) return true;
 #bye(Db::conf_dbs(array( Db::ROOT_DIR.'/etc/dbs.yaml','/etc/dbs.yaml' )));
index 36344c7d7ac70fe6453d301782cf5c0fec81e87c..0a344f796769133c0672ad8573696e0da8068891 100644 (file)
@@ -62,7 +62,8 @@ class NB {
    */
   public static function paliases($aliases) {
     foreach ($aliases as $short=>$long) {
-      DB::pdef($long,Db::p($short));
+      if (!preg_match('/^\s*$/',self::p($short))) DB::pset($long,Db::p($short));
+      #echo "===$short => $long\n";
       Db::pset($short,null);
     }
   }