From 37485b84e76310c5fbfab70a4da331c8ec07fbce Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Tue, 5 Dec 2017 02:51:16 +0000 Subject: [PATCH] lib/php/db/shell.php --- lib/php/db/shell.php | 17 ++++++++++++++--- lib/php/db/table.php | 4 ++++ 2 files changed, 18 insertions(+), 3 deletions(-) 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; -- 2.47.3