From: Nicolas Boisselier Date: Tue, 5 Dec 2017 02:51:16 +0000 (+0000) Subject: lib/php/db/shell.php X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=37485b84e76310c5fbfab70a4da331c8ec07fbce;p=nb.git lib/php/db/shell.php --- diff --git a/lib/php/db/shell.php b/lib/php/db/shell.php index 517dadf0..a7663f50 100755 --- a/lib/php/db/shell.php +++ b/lib/php/db/shell.php @@ -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': diff --git a/lib/php/db/table.php b/lib/php/db/table.php index 4384d556..7a79d85d 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -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;