From d39dc8eb1a9a743e12c2ca6c40673f09c895e84c Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Mon, 23 May 2016 23:55:10 +0100 Subject: [PATCH] help --- lib/php/db.php | 47 +++++++++-------------------------------------- 1 file changed, 9 insertions(+), 38 deletions(-) diff --git a/lib/php/db.php b/lib/php/db.php index c6d98203..480acb33 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -42,12 +42,6 @@ class Db extends nb { public $extras; public $formats = array( 'table','div','csv','xml','json','yaml' ); public $limits = array('10','20','50','100','500','1000'); - const help_criterias = ' - * or % for wildcar - ! to negate - ~ for regex - combine criterias with OR/AND - '; function __construct($opt = '') { @@ -355,28 +349,6 @@ class Db extends nb { # NB 28.03.16 return $this->conn->query("SELECT count(*) FROM ($sql) count",PDO::FETCH_COLUMN,0)->fetch(); # NB 28.03.16 } - function help($tables=null) { - if (!self::php_cli()) header('Content-type: text/plain'); - - if ($tables === null) $tables = array_keys($this->tables()); - $tables = join('',ar_map('" ".$a."\n"',$tables)); - - $criterias = join('',ar_map('" ".trim($a)."\n"',explode("\n",self::help_criterias))); - - return <<p('format',out::php_cli() ? 'csv' : 'table'),$rows,$head); return true; } @@ -407,9 +378,9 @@ EOF; foreach($actions as $action) { - if ($action == 'db.help') { - $this->out2(array( - array('db.help','This help'), + if ($action == 'db.help' or $action == 'help') { + $this->out(array( + array('[db.]help','This help'), array('[db.]dbs','List databases'), array('[db.]tables','List tables'), @@ -422,7 +393,7 @@ EOF; array('[table.]update','Update a record'), array('[table.]delete','Delete a record'), - ),array('command','description')); + ),array('action','description')); $return = true; } elseif ($action == 'db.tables' or $action == 'tables') { @@ -434,14 +405,14 @@ EOF; if (!empty($type) and strpos($t->type,$type) === false) continue; $rows[] = $t->infos(); } - $return = $this->out2($rows); + $return = $this->out($rows); } elseif ($action == 'db.conf') { - $return = $this->out2(array_values($this->conf)); + $return = $this->out(array_values($this->conf)); } elseif ($action == 'db.dbs' or $action == 'dbs') { - if (self::p('hash')) $return = $this->out2($this->conf); - else $return = $this->out2($this->dbs,"name"); + if (self::p('hash')) $return = $this->out($this->conf); + else $return = $this->out($this->dbs,"name"); } elseif ($r=self::class_action_out($this,$action)) { return $r; -- 2.47.3