250 |
kaklik |
1 |
<?php |
|
|
2 |
/* $Id: relation_cleanup.lib.php,v 2.4 2005/12/17 17:36:58 cybot_tm Exp $ */ |
|
|
3 |
// vim: expandtab sw=4 ts=4 sts=4: |
|
|
4 |
|
|
|
5 |
/** |
|
|
6 |
* Set of functions used for cleaning up phpMyAdmin tables |
|
|
7 |
*/ |
|
|
8 |
|
|
|
9 |
|
|
|
10 |
require_once('./libraries/relation.lib.php'); |
|
|
11 |
$cfgRelation = PMA_getRelationsParam(); |
|
|
12 |
|
|
|
13 |
function PMA_relationsCleanupColumn($db, $table, $column) { |
|
|
14 |
global $cfgRelation; |
|
|
15 |
if ($cfgRelation['commwork']) { |
|
|
16 |
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['column_info']) |
|
|
17 |
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' |
|
|
18 |
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'' |
|
|
19 |
. ' AND column_name = \'' . PMA_sqlAddslashes(urldecode($column)) . '\''; |
|
|
20 |
$rmv_rs = PMA_query_as_cu($remove_query); |
|
|
21 |
unset($remove_query); |
|
|
22 |
} |
|
|
23 |
|
|
|
24 |
if ($cfgRelation['displaywork']) { |
|
|
25 |
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_info']) |
|
|
26 |
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' |
|
|
27 |
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'' |
|
|
28 |
. ' AND display_field = \'' . PMA_sqlAddslashes(urldecode($column)) . '\''; |
|
|
29 |
$rmv_rs = PMA_query_as_cu($remove_query); |
|
|
30 |
unset($remove_query); |
|
|
31 |
} |
|
|
32 |
|
|
|
33 |
if ($cfgRelation['relwork']) { |
|
|
34 |
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation']) |
|
|
35 |
. ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\'' |
|
|
36 |
. ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\'' |
|
|
37 |
. ' AND master_field = \'' . PMA_sqlAddslashes(urldecode($column)) . '\''; |
|
|
38 |
$rmv_rs = PMA_query_as_cu($remove_query); |
|
|
39 |
unset($remove_query); |
|
|
40 |
|
|
|
41 |
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation']) |
|
|
42 |
. ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\'' |
|
|
43 |
. ' AND foreign_table = \'' . PMA_sqlAddslashes($table) . '\'' |
|
|
44 |
. ' AND foreign_field = \'' . PMA_sqlAddslashes(urldecode($column)) . '\''; |
|
|
45 |
$rmv_rs = PMA_query_as_cu($remove_query); |
|
|
46 |
unset($remove_query); |
|
|
47 |
} |
|
|
48 |
} |
|
|
49 |
|
|
|
50 |
function PMA_relationsCleanupTable($db, $table) { |
|
|
51 |
global $cfgRelation; |
|
|
52 |
|
|
|
53 |
if ($cfgRelation['commwork']) { |
|
|
54 |
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['column_info']) |
|
|
55 |
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' |
|
|
56 |
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''; |
|
|
57 |
$rmv_rs = PMA_query_as_cu($remove_query); |
|
|
58 |
unset($remove_query); |
|
|
59 |
} |
|
|
60 |
|
|
|
61 |
if ($cfgRelation['displaywork']) { |
|
|
62 |
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_info']) |
|
|
63 |
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' |
|
|
64 |
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''; |
|
|
65 |
$rmv_rs = PMA_query_as_cu($remove_query); |
|
|
66 |
unset($remove_query); |
|
|
67 |
} |
|
|
68 |
|
|
|
69 |
if ($cfgRelation['pdfwork']) { |
|
|
70 |
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) |
|
|
71 |
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' |
|
|
72 |
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''; |
|
|
73 |
$rmv_rs = PMA_query_as_cu($remove_query); |
|
|
74 |
unset($remove_query); |
|
|
75 |
} |
|
|
76 |
|
|
|
77 |
if ($cfgRelation['relwork']) { |
|
|
78 |
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation']) |
|
|
79 |
. ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\'' |
|
|
80 |
. ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\''; |
|
|
81 |
$rmv_rs = PMA_query_as_cu($remove_query); |
|
|
82 |
unset($remove_query); |
|
|
83 |
|
|
|
84 |
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation']) |
|
|
85 |
. ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\'' |
|
|
86 |
. ' AND foreign_table = \'' . PMA_sqlAddslashes($table) . '\''; |
|
|
87 |
$rmv_rs = PMA_query_as_cu($remove_query); |
|
|
88 |
unset($remove_query); |
|
|
89 |
} |
|
|
90 |
} |
|
|
91 |
|
|
|
92 |
function PMA_relationsCleanupDatabase($db) { |
|
|
93 |
global $cfgRelation; |
|
|
94 |
|
|
|
95 |
if ($cfgRelation['commwork']) { |
|
|
96 |
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['column_info']) |
|
|
97 |
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''; |
|
|
98 |
$rmv_rs = PMA_query_as_cu($remove_query); |
|
|
99 |
unset($remove_query); |
|
|
100 |
} |
|
|
101 |
|
|
|
102 |
if ($cfgRelation['bookmarkwork']) { |
|
|
103 |
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['bookmark']) |
|
|
104 |
. ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\''; |
|
|
105 |
$rmv_rs = PMA_query_as_cu($remove_query); |
|
|
106 |
unset($remove_query); |
|
|
107 |
} |
|
|
108 |
|
|
|
109 |
if ($cfgRelation['displaywork']) { |
|
|
110 |
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_info']) |
|
|
111 |
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''; |
|
|
112 |
$rmv_rs = PMA_query_as_cu($remove_query); |
|
|
113 |
unset($remove_query); |
|
|
114 |
} |
|
|
115 |
|
|
|
116 |
if ($cfgRelation['pdfwork']) { |
|
|
117 |
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages']) |
|
|
118 |
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''; |
|
|
119 |
$rmv_rs = PMA_query_as_cu($remove_query); |
|
|
120 |
unset($remove_query); |
|
|
121 |
|
|
|
122 |
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) |
|
|
123 |
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''; |
|
|
124 |
$rmv_rs = PMA_query_as_cu($remove_query); |
|
|
125 |
unset($remove_query); |
|
|
126 |
} |
|
|
127 |
|
|
|
128 |
if ($cfgRelation['relwork']) { |
|
|
129 |
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation']) |
|
|
130 |
. ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\''; |
|
|
131 |
$rmv_rs = PMA_query_as_cu($remove_query); |
|
|
132 |
unset($remove_query); |
|
|
133 |
|
|
|
134 |
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation']) |
|
|
135 |
. ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\''; |
|
|
136 |
$rmv_rs = PMA_query_as_cu($remove_query); |
|
|
137 |
unset($remove_query); |
|
|
138 |
} |
|
|
139 |
} |
|
|
140 |
|
|
|
141 |
?> |