2.11.1.2 release
[phpmyadmin/arisferyanto.git] / libraries / relation_cleanup.lib.php
blob65d034e9d982abd685a8c7ec9ea8ff869f034e09
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Set of functions used for cleaning up phpMyAdmin tables
6 * @version $Id$
7 */
9 /**
12 require_once './libraries/relation.lib.php';
13 $cfgRelation = PMA_getRelationsParam();
15 function PMA_relationsCleanupColumn($db, $table, $column) {
16 global $cfgRelation;
17 if ($cfgRelation['commwork']) {
18 $remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['column_info'])
19 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
20 . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
21 . ' AND column_name = \'' . PMA_sqlAddslashes(urldecode($column)) . '\'';
22 $rmv_rs = PMA_query_as_cu($remove_query);
23 unset($remove_query);
26 if ($cfgRelation['displaywork']) {
27 $remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_info'])
28 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
29 . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
30 . ' AND display_field = \'' . PMA_sqlAddslashes(urldecode($column)) . '\'';
31 $rmv_rs = PMA_query_as_cu($remove_query);
32 unset($remove_query);
35 if ($cfgRelation['relwork']) {
36 $remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation'])
37 . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\''
38 . ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\''
39 . ' AND master_field = \'' . PMA_sqlAddslashes(urldecode($column)) . '\'';
40 $rmv_rs = PMA_query_as_cu($remove_query);
41 unset($remove_query);
43 $remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation'])
44 . ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\''
45 . ' AND foreign_table = \'' . PMA_sqlAddslashes($table) . '\''
46 . ' AND foreign_field = \'' . PMA_sqlAddslashes(urldecode($column)) . '\'';
47 $rmv_rs = PMA_query_as_cu($remove_query);
48 unset($remove_query);
52 function PMA_relationsCleanupTable($db, $table) {
53 global $cfgRelation;
55 if ($cfgRelation['commwork']) {
56 $remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['column_info'])
57 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
58 . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
59 $rmv_rs = PMA_query_as_cu($remove_query);
60 unset($remove_query);
63 if ($cfgRelation['displaywork']) {
64 $remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_info'])
65 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
66 . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
67 $rmv_rs = PMA_query_as_cu($remove_query);
68 unset($remove_query);
71 if ($cfgRelation['pdfwork']) {
72 $remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
73 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
74 . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
75 $rmv_rs = PMA_query_as_cu($remove_query);
76 unset($remove_query);
79 if ($cfgRelation['relwork']) {
80 $remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation'])
81 . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\''
82 . ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\'';
83 $rmv_rs = PMA_query_as_cu($remove_query);
84 unset($remove_query);
86 $remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation'])
87 . ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\''
88 . ' AND foreign_table = \'' . PMA_sqlAddslashes($table) . '\'';
89 $rmv_rs = PMA_query_as_cu($remove_query);
90 unset($remove_query);
94 function PMA_relationsCleanupDatabase($db) {
95 global $cfgRelation;
97 if ($cfgRelation['commwork']) {
98 $remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['column_info'])
99 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
100 $rmv_rs = PMA_query_as_cu($remove_query);
101 unset($remove_query);
104 if ($cfgRelation['bookmarkwork']) {
105 $remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['bookmark'])
106 . ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\'';
107 $rmv_rs = PMA_query_as_cu($remove_query);
108 unset($remove_query);
111 if ($cfgRelation['displaywork']) {
112 $remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_info'])
113 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
114 $rmv_rs = PMA_query_as_cu($remove_query);
115 unset($remove_query);
118 if ($cfgRelation['pdfwork']) {
119 $remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages'])
120 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
121 $rmv_rs = PMA_query_as_cu($remove_query);
122 unset($remove_query);
124 $remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
125 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
126 $rmv_rs = PMA_query_as_cu($remove_query);
127 unset($remove_query);
130 if ($cfgRelation['relwork']) {
131 $remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation'])
132 . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\'';
133 $rmv_rs = PMA_query_as_cu($remove_query);
134 unset($remove_query);
136 $remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation'])
137 . ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\'';
138 $rmv_rs = PMA_query_as_cu($remove_query);
139 unset($remove_query);