From: Nicolas Boisselier Date: Fri, 12 Aug 2016 00:13:47 +0000 (+0200) Subject: Bed X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=e6320c04324fb62f9cfcd2d0785137acc206b1cc;p=nb.git Bed --- diff --git a/bin/dbq b/bin/dbq index bc939a24..eed01438 100755 --- 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', diff --git a/bin/dbq-shell b/bin/dbq-shell index d251fcb4..30770d05 100755 --- a/bin/dbq-shell +++ b/bin/dbq-shell @@ -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" diff --git a/lib/php/db.php b/lib/php/db.php index 629419c9..a863fe07 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -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 ?> diff --git a/lib/php/db/index.php b/lib/php/db/index.php index ec9b0716..30e832ed 100755 --- a/lib/php/db/index.php +++ b/lib/php/db/index.php @@ -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' ))); diff --git a/lib/php/nb.php b/lib/php/nb.php index 36344c7d..0a344f79 100644 --- a/lib/php/nb.php +++ b/lib/php/nb.php @@ -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); } }