]> git.nbdom.net Git - nb.git/commitdiff
lib/php/db/shell.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 5 Dec 2017 02:51:16 +0000 (02:51 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 5 Dec 2017 02:51:16 +0000 (02:51 +0000)
lib/php/db/shell.php
lib/php/db/table.php

index 517dadf06012c19e0cf4515e2081a3307f06064b..a7663f50c24379e3e875960da0894dd7168f3bd8 100755 (executable)
@@ -94,16 +94,27 @@ function db_shell_action($k,$v) {
         break;
       }
 
-      if (strpos('table.insert table.update table.replace',Db::p('action'))) {
+      if (empty($Db)) {
+        echo "!Database is missing, use db= or try help\n";
+        break;
+      }
+
+      if (strpos('table.insert table.update table.replace',$v)) {
         $_POST = Db::p();
       }
 
-      if (empty($Db)) {
-        echo "!Database is missing, use db= or try help\n";
+      if ($v == 'begin_transaction') {
+        $Db->query('BEGIN TRANSACTION');
+        break;
+      }
+
+      if ($v == 'commit') {
+        $Db->query('COMMIT');
         break;
       }
 
       $Db->action($Db->p('action'),$Table);
+      #if ($v) $Db->action($v,$Table);
       break;
 
     case 'db':
index 4384d556600408cd902adedddad8dbe6939dd207..7a79d85df48170d47e2f285cfd911e9a2acac9dd 100644 (file)
@@ -1858,6 +1858,10 @@ Class Table extends nb {
       $this->out($e);
       return true;
 
+    } elseif ($action == 'table.truncate') {
+      $this->db()->query('TRUNCATE '.$this->sql_name());
+      return true;
+
     } elseif (self::class_action_out($this,$action) !== null) {
       return true;