enclose multi-drop tables in a transaction
authorioguix <ioguix>
Sun, 16 Dec 2007 01:30:14 +0000 (01:30 +0000)
committerioguix <ioguix>
Sun, 16 Dec 2007 01:30:14 +0000 (01:30 +0000)
tables.php

index b50eace943174c84e782126123ada2ef9e8c55ce..8384a3e17df85deafb221b85d44e5102bbd63819 100644 (file)
@@ -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
                        //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<br />', htmlentities($t), $lang['strtabledropped']);
-                                       else {
-                                               doDefault(sprintf('%s%s: %s<br />', $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<br />', htmlentities($t), $lang['strtabledropped']);
+                                               else {
+                                                       $data->endTransaction();
+                                                       doDefault(sprintf('%s%s: %s<br />', $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) {