From a224c5f35f66252c96fb58deac0496b893e890b0 Mon Sep 17 00:00:00 2001 From: ioguix Date: Sun, 16 Dec 2007 01:30:14 +0000 Subject: [PATCH] enclose multi-drop tables in a transaction --- tables.php | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/tables.php b/tables.php index b50eace9..8384a3e1 100644 --- a/tables.php +++ b/tables.php @@ -3,7 +3,7 @@ /** * List tables in a database * - * $Id: tables.php,v 1.106 2007/10/17 21:40:19 ioguix Exp $ + * $Id: tables.php,v 1.107 2007/12/16 01:30:14 ioguix Exp $ */ // Include application functions @@ -696,18 +696,25 @@ //If multi drop if (is_array($_REQUEST['table'])) { $msg=''; - foreach($_REQUEST['table'] as $t) { - $status = $data->dropTable($t, isset($_POST['cascade'])); - if ($status == 0) - $msg.= sprintf('%s: %s
', htmlentities($t), $lang['strtabledropped']); - else { - doDefault(sprintf('%s%s: %s
', $msg, htmlentities($t), $lang['strtabledroppedbad'])); - return; + $status = $data->beginTransaction(); + if ($status == 0) { + foreach($_REQUEST['table'] as $t) { + $status = $data->dropTable($t, isset($_POST['cascade'])); + if ($status == 0) + $msg.= sprintf('%s: %s
', htmlentities($t), $lang['strtabledropped']); + else { + $data->endTransaction(); + doDefault(sprintf('%s%s: %s
', $msg, htmlentities($t), $lang['strtabledroppedbad'])); + return; + } } } - // Everything went fine, back to the Default page.... - $_reload_browser = true; - doDefault($msg); + if($data->endTransaction() == 0) { + // Everything went fine, back to the Default page.... + $_reload_browser = true; + doDefault($msg); + } + else doDefault($lang['strtabledroppedbad']); } else { $status = $data->dropTable($_POST['table'], isset($_POST['cascade'])); if ($status == 0) { -- 2.39.5