From 69cefd5bf9d68ab13b68bf4a06ee4e0724517bc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 6 Jun 2003 10:02:58 +0000 Subject: [PATCH] Cleanup phpMyAdmin tables also after multi submit actions (RFE #749989). --- ChangeLog | 2 + libraries/relation_cleanup.lib.php3 | 145 ++++++++++++++++++++++++++++ mult_submits.inc.php3 | 7 ++ sql.php3 | 126 +----------------------- 4 files changed, 159 insertions(+), 121 deletions(-) create mode 100644 libraries/relation_cleanup.lib.php3 diff --git a/ChangeLog b/ChangeLog index fcaf4e534..8de1e3937 100755 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,8 @@ $Source$ 2003-06-06 Michal Cihar * mult_submits.inc.php3: Missing ;. + * libraries/relation_cleanup.lib.php3, mult_submits.inc.php3, sql.php3: + Cleanup phpMyAdmin tables also after multi submit actions (RFE #749989). 2003-06-05 Marc Delisle * Documentation.html: new faq 6.20 about CREATE TEMPORARY TABLES diff --git a/libraries/relation_cleanup.lib.php3 b/libraries/relation_cleanup.lib.php3 new file mode 100644 index 000000000..0f491ceb7 --- /dev/null +++ b/libraries/relation_cleanup.lib.php3 @@ -0,0 +1,145 @@ + diff --git a/mult_submits.inc.php3 b/mult_submits.inc.php3 index 5c0cb4ace..0cd984024 100644 --- a/mult_submits.inc.php3 +++ b/mult_submits.inc.php3 @@ -158,17 +158,23 @@ if (!empty($submit_mult) && !empty($what)) { */ else if ($mult_btn == $strYes) { + if ($query_type == 'drop_db' || $query_type == 'drop_tbl' || $query_type == 'drop_fld') { + include('./libraries/relation_cleanup.lib.php3'); + } + $sql_query = ''; $selected_cnt = count($selected); for ($i = 0; $i < $selected_cnt; $i++) { switch ($query_type) { case 'drop_db': + PMA_relationsCleanupDatabase($selected[$i]); $a_query = 'DROP DATABASE ' . PMA_backquote(urldecode($selected[$i])); $reload = 1; break; case 'drop_tbl': + PMA_relationsCleanupTable($db, $selected[$i]); $sql_query .= (empty($sql_query) ? 'DROP TABLE ' : ', ') . PMA_backquote(urldecode($selected[$i])) . (($i == $selected_cnt-1) ? ';' : ''); @@ -205,6 +211,7 @@ else if ($mult_btn == $strYes) { break; case 'drop_fld': + PMA_relationsCleanupTable($db, $table, $selected[$i]); $sql_query .= (empty($sql_query) ? 'ALTER TABLE ' . PMA_backquote($table) : ',') . ' DROP ' . PMA_backquote(urldecode($selected[$i])) . (($i == $selected_cnt-1) ? ';' : ''); diff --git a/sql.php3 b/sql.php3 index e451cac2a..63e828539 100755 --- a/sql.php3 +++ b/sql.php3 @@ -457,95 +457,12 @@ else { // garvin: if a table or database gets dropped, check column comments. if (isset($purge) && $purge == '1') { - include('./libraries/relation.lib.php3'); - $cfgRelation = PMA_getRelationsParam(); + include('./libraries/relation_cleanup.lib.php3'); if (isset($table) && isset($db) && !empty($table) && !empty($db)) { - // garvin: Only a table is deleted. Remove all references in PMA_* - if ($cfgRelation['commwork']) { - $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['column_info']) - . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' - . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''; - $rmv_rs = PMA_query_as_cu($remove_query); - unset($rmv_query); - } - - if ($cfgRelation['displaywork']) { - $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['table_info']) - . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' - . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''; - $rmv_rs = PMA_query_as_cu($remove_query); - unset($rmv_query); - } - - if ($cfgRelation['pdfwork']) { - $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['table_coords']) - . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' - . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''; - $rmv_rs = PMA_query_as_cu($remove_query); - unset($rmv_query); - } - - if ($cfgRelation['relwork']) { - $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation']) - . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\'' - . ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\''; - $rmv_rs = PMA_query_as_cu($remove_query); - unset($rmv_query); - - $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation']) - . ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\'' - . ' AND foreign_table = \'' . PMA_sqlAddslashes($table) . '\''; - $rmv_rs = PMA_query_as_cu($remove_query); - unset($rmv_query); - } + PMA_relationsCleanupTable($db, $table); } elseif (isset($db) && !empty($db)) { - // garvin: A whole DB gets deleted. Remove all references in PMA_* - if ($cfgRelation['commwork']) { - $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['column_info']) - . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''; - $rmv_rs = PMA_query_as_cu($remove_query); - unset($rmv_query); - } - - if ($cfgRelation['bookmarkwork']) { - $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['bookmark']) - . ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\''; - $rmv_rs = PMA_query_as_cu($remove_query); - unset($rmv_query); - } - - if ($cfgRelation['displaywork']) { - $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['table_info']) - . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''; - $rmv_rs = PMA_query_as_cu($remove_query); - unset($rmv_query); - } - - if ($cfgRelation['pdfwork']) { - $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['pdf_pages']) - . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''; - $rmv_rs = PMA_query_as_cu($remove_query); - unset($rmv_query); - - $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['table_coords']) - . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''; - $rmv_rs = PMA_query_as_cu($remove_query); - unset($rmv_query); - } - - if ($cfgRelation['relwork']) { - $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation']) - . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\''; - $rmv_rs = PMA_query_as_cu($remove_query); - unset($rmv_query); - - $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation']) - . ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\''; - $rmv_rs = PMA_query_as_cu($remove_query); - unset($rmv_query); - } - + PMA_relationsCleanupDatabase($db); } else { // garvin: VOID. No DB/Table gets deleted. } // end if relation-stuff @@ -555,42 +472,9 @@ else { if (isset($cpurge) && $cpurge == '1' && isset($purgekey) && isset($db) && isset($table) && !empty($db) && !empty($table) && !empty($purgekey)) { - include('./libraries/relation.lib.php3'); - $cfgRelation = PMA_getRelationsParam(); + include('./libraries/relation_cleanup.lib.php3'); + PMA_relationsCleanupColumnt($db, $table, $purgekey); - if ($cfgRelation['commwork']) { - $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['column_info']) - . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' - . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'' - . ' AND column_name = \'' . PMA_sqlAddslashes(urldecode($purgekey)) . '\''; - $rmv_rs = PMA_query_as_cu($remove_query); - unset($rmv_query); - } - - if ($cfgRelation['displaywork']) { - $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['table_info']) - . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' - . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'' - . ' AND display_field = \'' . PMA_sqlAddslashes(urldecode($purgekey)) . '\''; - $rmv_rs = PMA_query_as_cu($remove_query); - unset($rmv_query); - } - - if ($cfgRelation['relwork']) { - $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation']) - . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\'' - . ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\'' - . ' AND master_field = \'' . PMA_sqlAddslashes(urldecode($purgekey)) . '\''; - $rmv_rs = PMA_query_as_cu($remove_query); - unset($rmv_query); - - $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation']) - . ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\'' - . ' AND foreign_table = \'' . PMA_sqlAddslashes($table) . '\'' - . ' AND foreign_field = \'' . PMA_sqlAddslashes(urldecode($purgekey)) . '\''; - $rmv_rs = PMA_query_as_cu($remove_query); - unset($rmv_query); - } } // end if column PMA_* purge } // end else "didn't ask to see php code"