2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Set of functions used for cleaning up phpMyAdmin tables
10 * Cleanup column related relation stuff
12 * @param string $db database name
13 * @param string $table table name
14 * @param string $column column name
18 function PMA_relationsCleanupColumn($db, $table, $column)
20 $cfgRelation = PMA_getRelationsParam();
22 if ($cfgRelation['commwork']) {
23 $remove_query = 'DELETE FROM '
24 . PMA\libraries\Util
::backquote($cfgRelation['db'])
25 . '.' . PMA\libraries\Util
::backquote($cfgRelation['column_info'])
26 . ' WHERE db_name = \'' . PMA\libraries\Util
::sqlAddSlashes($db) . '\''
27 . ' AND table_name = \'' . PMA\libraries\Util
::sqlAddSlashes($table)
29 . ' AND column_name = \'' . PMA\libraries\Util
::sqlAddSlashes($column)
31 PMA_queryAsControlUser($remove_query);
34 if ($cfgRelation['displaywork']) {
35 $remove_query = 'DELETE FROM '
36 . PMA\libraries\Util
::backquote($cfgRelation['db'])
37 . '.' . PMA\libraries\Util
::backquote($cfgRelation['table_info'])
38 . ' WHERE db_name = \'' . PMA\libraries\Util
::sqlAddSlashes($db) . '\''
39 . ' AND table_name = \'' . PMA\libraries\Util
::sqlAddSlashes($table)
41 . ' AND display_field = \'' . PMA\libraries\Util
::sqlAddSlashes($column)
43 PMA_queryAsControlUser($remove_query);
46 if ($cfgRelation['relwork']) {
47 $remove_query = 'DELETE FROM '
48 . PMA\libraries\Util
::backquote($cfgRelation['db'])
49 . '.' . PMA\libraries\Util
::backquote($cfgRelation['relation'])
50 . ' WHERE master_db = \'' . PMA\libraries\Util
::sqlAddSlashes($db)
52 . ' AND master_table = \'' . PMA\libraries\Util
::sqlAddSlashes($table)
54 . ' AND master_field = \'' . PMA\libraries\Util
::sqlAddSlashes($column)
56 PMA_queryAsControlUser($remove_query);
58 $remove_query = 'DELETE FROM '
59 . PMA\libraries\Util
::backquote($cfgRelation['db'])
60 . '.' . PMA\libraries\Util
::backquote($cfgRelation['relation'])
61 . ' WHERE foreign_db = \'' . PMA\libraries\Util
::sqlAddSlashes($db)
63 . ' AND foreign_table = \'' . PMA\libraries\Util
::sqlAddSlashes($table)
65 . ' AND foreign_field = \'' . PMA\libraries\Util
::sqlAddSlashes($column)
67 PMA_queryAsControlUser($remove_query);
72 * Cleanup table related relation stuff
74 * @param string $db database name
75 * @param string $table table name
79 function PMA_relationsCleanupTable($db, $table)
81 $cfgRelation = PMA_getRelationsParam();
83 if ($cfgRelation['commwork']) {
84 $remove_query = 'DELETE FROM '
85 . PMA\libraries\Util
::backquote($cfgRelation['db'])
86 . '.' . PMA\libraries\Util
::backquote($cfgRelation['column_info'])
87 . ' WHERE db_name = \'' . PMA\libraries\Util
::sqlAddSlashes($db) . '\''
88 . ' AND table_name = \'' . PMA\libraries\Util
::sqlAddSlashes($table)
90 PMA_queryAsControlUser($remove_query);
93 if ($cfgRelation['displaywork']) {
94 $remove_query = 'DELETE FROM '
95 . PMA\libraries\Util
::backquote($cfgRelation['db'])
96 . '.' . PMA\libraries\Util
::backquote($cfgRelation['table_info'])
97 . ' WHERE db_name = \'' . PMA\libraries\Util
::sqlAddSlashes($db) . '\''
98 . ' AND table_name = \'' . PMA\libraries\Util
::sqlAddSlashes($table)
100 PMA_queryAsControlUser($remove_query);
103 if ($cfgRelation['pdfwork']) {
104 $remove_query = 'DELETE FROM '
105 . PMA\libraries\Util
::backquote($cfgRelation['db'])
106 . '.' . PMA\libraries\Util
::backquote($cfgRelation['table_coords'])
107 . ' WHERE db_name = \'' . PMA\libraries\Util
::sqlAddSlashes($db) . '\''
108 . ' AND table_name = \'' . PMA\libraries\Util
::sqlAddSlashes($table)
110 PMA_queryAsControlUser($remove_query);
113 if ($cfgRelation['relwork']) {
114 $remove_query = 'DELETE FROM '
115 . PMA\libraries\Util
::backquote($cfgRelation['db'])
116 . '.' . PMA\libraries\Util
::backquote($cfgRelation['relation'])
117 . ' WHERE master_db = \'' . PMA\libraries\Util
::sqlAddSlashes($db)
119 . ' AND master_table = \'' . PMA\libraries\Util
::sqlAddSlashes($table)
121 PMA_queryAsControlUser($remove_query);
123 $remove_query = 'DELETE FROM '
124 . PMA\libraries\Util
::backquote($cfgRelation['db'])
125 . '.' . PMA\libraries\Util
::backquote($cfgRelation['relation'])
126 . ' WHERE foreign_db = \'' . PMA\libraries\Util
::sqlAddSlashes($db)
128 . ' AND foreign_table = \'' . PMA\libraries\Util
::sqlAddSlashes($table)
130 PMA_queryAsControlUser($remove_query);
133 if ($cfgRelation['uiprefswork']) {
134 $remove_query = 'DELETE FROM '
135 . PMA\libraries\Util
::backquote($cfgRelation['db'])
136 . '.' . PMA\libraries\Util
::backquote($cfgRelation['table_uiprefs'])
137 . ' WHERE db_name = \'' . PMA\libraries\Util
::sqlAddSlashes($db) . '\''
138 . ' AND table_name = \'' . PMA\libraries\Util
::sqlAddSlashes($table)
140 PMA_queryAsControlUser($remove_query);
143 if ($cfgRelation['navwork']) {
144 $remove_query = 'DELETE FROM '
145 . PMA\libraries\Util
::backquote($cfgRelation['db'])
146 . '.' . PMA\libraries\Util
::backquote($cfgRelation['navigationhiding'])
147 . ' WHERE db_name = \'' . PMA\libraries\Util
::sqlAddSlashes($db) . '\''
148 . ' AND (table_name = \'' . PMA\libraries\Util
::sqlAddSlashes($table)
150 . ' OR (item_name = \'' . PMA\libraries\Util
::sqlAddSlashes($table)
152 . ' AND item_type = \'table\'))';
153 PMA_queryAsControlUser($remove_query);
158 * Cleanup database related relation stuff
160 * @param string $db database name
164 function PMA_relationsCleanupDatabase($db)
166 $cfgRelation = PMA_getRelationsParam();
168 if ($cfgRelation['commwork']) {
169 $remove_query = 'DELETE FROM '
170 . PMA\libraries\Util
::backquote($cfgRelation['db'])
171 . '.' . PMA\libraries\Util
::backquote($cfgRelation['column_info'])
172 . ' WHERE db_name = \'' . PMA\libraries\Util
::sqlAddSlashes($db) . '\'';
173 PMA_queryAsControlUser($remove_query);
176 if ($cfgRelation['bookmarkwork']) {
177 $remove_query = 'DELETE FROM '
178 . PMA\libraries\Util
::backquote($cfgRelation['db'])
179 . '.' . PMA\libraries\Util
::backquote($cfgRelation['bookmark'])
180 . ' WHERE dbase = \'' . PMA\libraries\Util
::sqlAddSlashes($db) . '\'';
181 PMA_queryAsControlUser($remove_query);
184 if ($cfgRelation['displaywork']) {
185 $remove_query = 'DELETE FROM '
186 . PMA\libraries\Util
::backquote($cfgRelation['db'])
187 . '.' . PMA\libraries\Util
::backquote($cfgRelation['table_info'])
188 . ' WHERE db_name = \'' . PMA\libraries\Util
::sqlAddSlashes($db) . '\'';
189 PMA_queryAsControlUser($remove_query);
192 if ($cfgRelation['pdfwork']) {
193 $remove_query = 'DELETE FROM '
194 . PMA\libraries\Util
::backquote($cfgRelation['db'])
195 . '.' . PMA\libraries\Util
::backquote($cfgRelation['pdf_pages'])
196 . ' WHERE db_name = \'' . PMA\libraries\Util
::sqlAddSlashes($db) . '\'';
197 PMA_queryAsControlUser($remove_query);
199 $remove_query = 'DELETE FROM '
200 . PMA\libraries\Util
::backquote($cfgRelation['db'])
201 . '.' . PMA\libraries\Util
::backquote($cfgRelation['table_coords'])
202 . ' WHERE db_name = \'' . PMA\libraries\Util
::sqlAddSlashes($db) . '\'';
203 PMA_queryAsControlUser($remove_query);
206 if ($cfgRelation['relwork']) {
207 $remove_query = 'DELETE FROM '
208 . PMA\libraries\Util
::backquote($cfgRelation['db'])
209 . '.' . PMA\libraries\Util
::backquote($cfgRelation['relation'])
210 . ' WHERE master_db = \''
211 . PMA\libraries\Util
::sqlAddSlashes($db) . '\'';
212 PMA_queryAsControlUser($remove_query);
214 $remove_query = 'DELETE FROM '
215 . PMA\libraries\Util
::backquote($cfgRelation['db'])
216 . '.' . PMA\libraries\Util
::backquote($cfgRelation['relation'])
217 . ' WHERE foreign_db = \'' . PMA\libraries\Util
::sqlAddSlashes($db)
219 PMA_queryAsControlUser($remove_query);
222 if ($cfgRelation['uiprefswork']) {
223 $remove_query = 'DELETE FROM '
224 . PMA\libraries\Util
::backquote($cfgRelation['db'])
225 . '.' . PMA\libraries\Util
::backquote($cfgRelation['table_uiprefs'])
226 . ' WHERE db_name = \'' . PMA\libraries\Util
::sqlAddSlashes($db) . '\'';
227 PMA_queryAsControlUser($remove_query);
230 if ($cfgRelation['navwork']) {
231 $remove_query = 'DELETE FROM '
232 . PMA\libraries\Util
::backquote($cfgRelation['db'])
233 . '.' . PMA\libraries\Util
::backquote($cfgRelation['navigationhiding'])
234 . ' WHERE db_name = \'' . PMA\libraries\Util
::sqlAddSlashes($db) . '\'';
235 PMA_queryAsControlUser($remove_query);
238 if ($cfgRelation['savedsearcheswork']) {
239 $remove_query = 'DELETE FROM '
240 . PMA\libraries\Util
::backquote($cfgRelation['db'])
241 . '.' . PMA\libraries\Util
::backquote($cfgRelation['savedsearches'])
242 . ' WHERE db_name = \'' . PMA\libraries\Util
::sqlAddSlashes($db) . '\'';
243 PMA_queryAsControlUser($remove_query);
246 if ($cfgRelation['centralcolumnswork']) {
247 $remove_query = 'DELETE FROM '
248 . PMA\libraries\Util
::backquote($cfgRelation['db'])
249 . '.' . PMA\libraries\Util
::backquote($cfgRelation['central_columns'])
250 . ' WHERE db_name = \'' . PMA\libraries\Util
::sqlAddSlashes($db) . '\'';
251 PMA_queryAsControlUser($remove_query);
256 * Cleanup user related relation stuff
258 * @param string $username username
262 function PMA_relationsCleanupUser($username)
264 $cfgRelation = PMA_getRelationsParam();
266 if ($cfgRelation['bookmarkwork']) {
267 $remove_query = "DELETE FROM "
268 . PMA\libraries\Util
::backquote($cfgRelation['db'])
269 . "." . PMA\libraries\Util
::backquote($cfgRelation['bookmark'])
270 . " WHERE `user` = '" . PMA\libraries\Util
::sqlAddSlashes($username)
272 PMA_queryAsControlUser($remove_query);
275 if ($cfgRelation['historywork']) {
276 $remove_query = "DELETE FROM "
277 . PMA\libraries\Util
::backquote($cfgRelation['db'])
278 . "." . PMA\libraries\Util
::backquote($cfgRelation['history'])
279 . " WHERE `username` = '" . PMA\libraries\Util
::sqlAddSlashes($username)
281 PMA_queryAsControlUser($remove_query);
284 if ($cfgRelation['recentwork']) {
285 $remove_query = "DELETE FROM "
286 . PMA\libraries\Util
::backquote($cfgRelation['db'])
287 . "." . PMA\libraries\Util
::backquote($cfgRelation['recent'])
288 . " WHERE `username` = '" . PMA\libraries\Util
::sqlAddSlashes($username)
290 PMA_queryAsControlUser($remove_query);
293 if ($cfgRelation['favoritework']) {
294 $remove_query = "DELETE FROM "
295 . PMA\libraries\Util
::backquote($cfgRelation['db'])
296 . "." . PMA\libraries\Util
::backquote($cfgRelation['favorite'])
297 . " WHERE `username` = '" . PMA\libraries\Util
::sqlAddSlashes($username)
299 PMA_queryAsControlUser($remove_query);
302 if ($cfgRelation['uiprefswork']) {
303 $remove_query = "DELETE FROM "
304 . PMA\libraries\Util
::backquote($cfgRelation['db'])
305 . "." . PMA\libraries\Util
::backquote($cfgRelation['table_uiprefs'])
306 . " WHERE `username` = '" . PMA\libraries\Util
::sqlAddSlashes($username)
308 PMA_queryAsControlUser($remove_query);
311 if ($cfgRelation['userconfigwork']) {
312 $remove_query = "DELETE FROM "
313 . PMA\libraries\Util
::backquote($cfgRelation['db'])
314 . "." . PMA\libraries\Util
::backquote($cfgRelation['userconfig'])
315 . " WHERE `username` = '" . PMA\libraries\Util
::sqlAddSlashes($username)
317 PMA_queryAsControlUser($remove_query);
320 if ($cfgRelation['menuswork']) {
321 $remove_query = "DELETE FROM "
322 . PMA\libraries\Util
::backquote($cfgRelation['db'])
323 . "." . PMA\libraries\Util
::backquote($cfgRelation['users'])
324 . " WHERE `username` = '" . PMA\libraries\Util
::sqlAddSlashes($username)
326 PMA_queryAsControlUser($remove_query);
329 if ($cfgRelation['navwork']) {
330 $remove_query = "DELETE FROM "
331 . PMA\libraries\Util
::backquote($cfgRelation['db'])
332 . "." . PMA\libraries\Util
::backquote($cfgRelation['navigationhiding'])
333 . " WHERE `username` = '" . PMA\libraries\Util
::sqlAddSlashes($username)
335 PMA_queryAsControlUser($remove_query);
338 if ($cfgRelation['savedsearcheswork']) {
339 $remove_query = "DELETE FROM "
340 . PMA\libraries\Util
::backquote($cfgRelation['db'])
341 . "." . PMA\libraries\Util
::backquote($cfgRelation['savedsearches'])
342 . " WHERE `username` = '" . PMA\libraries\Util
::sqlAddSlashes($username)
344 PMA_queryAsControlUser($remove_query);
347 if ($cfgRelation['designersettingswork']) {
348 $remove_query = "DELETE FROM "
349 . PMA\libraries\Util
::backquote($cfgRelation['db'])
350 . "." . PMA\libraries\Util
::backquote($cfgRelation['designer_settings'])
351 . " WHERE `username` = '" . PMA\libraries\Util
::sqlAddSlashes($username)
353 PMA_queryAsControlUser($remove_query);