]> git.nbdom.net Git - nb.git/commitdiff
lib/php/db/shell.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 29 Nov 2017 01:42:24 +0000 (01:42 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 29 Nov 2017 01:42:24 +0000 (01:42 +0000)
lib/php/db/shell.php

index cecd60b3c1ecf9a568018eab4438560dc6c6fd4c..552e3d26b8f2e13b61d81d5005caf7efebb5a7be 100755 (executable)
@@ -31,6 +31,20 @@ while($line = fgets(STDIN)){
   # Exit command
   if ($line == 'quit' or $line == 'q') break;
 
+  # Help
+  if ($line == 'help' or $line == 'h') {
+    $line = str_repeat('-',20)."\n";
+    echo $line . trim("
+help,h
+quit,q
+db=[NAME]
+table=[NAME]
+action,a=[ls,reset]
+    ")."\n" . $line;
+
+    continue;
+  }
+
   # Set params
   while ($line and (0
     or preg_match("/^([\w\.]+)='([^']+)'/",$line,$args)
@@ -66,6 +80,10 @@ function db_shell_action($k,$v) {
         break;
       }
 
+      if (empty($Db)) {
+        echo "Database is missing, try help\n";
+        break;
+      }
       #bye($Db::p());
       if ($Db->p('debug') == 'shell') {
         debug($Db->p());