3.2.5
[phpmyadmin/dkf.git] / libraries / relation_cleanup.lib.php
blob6c2c7895cb8c9594389fcf225e8993f3e1e2435c
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 * @package phpMyAdmin
8 */
9 if (! defined('PHPMYADMIN')) {
10 exit;
13 /**
16 require_once './libraries/relation.lib.php';
18 /**
19 * Cleanu column related relation stuff
21 * @uses PMA_getRelationsParam()
22 * @uses PMA_backquote()
23 * @uses PMA_sqlAddslashes()
24 * @uses PMA_query_as_controluser()
25 * @param string $db
26 * @param string $table
27 * @param string $column
29 function PMA_relationsCleanupColumn($db, $table, $column)
31 $cfgRelation = PMA_getRelationsParam();
33 if ($cfgRelation['commwork']) {
34 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info'])
35 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
36 . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
37 . ' AND column_name = \'' . PMA_sqlAddslashes($column) . '\'';
38 PMA_query_as_controluser($remove_query);
41 if ($cfgRelation['displaywork']) {
42 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['table_info'])
43 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
44 . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
45 . ' AND display_field = \'' . PMA_sqlAddslashes($column) . '\'';
46 PMA_query_as_controluser($remove_query);
49 if ($cfgRelation['relwork']) {
50 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['relation'])
51 . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\''
52 . ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\''
53 . ' AND master_field = \'' . PMA_sqlAddslashes($column) . '\'';
54 PMA_query_as_controluser($remove_query);
56 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['relation'])
57 . ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\''
58 . ' AND foreign_table = \'' . PMA_sqlAddslashes($table) . '\''
59 . ' AND foreign_field = \'' . PMA_sqlAddslashes($column) . '\'';
60 PMA_query_as_controluser($remove_query);
64 /**
65 * Cleanup table related relation stuff
67 * @uses PMA_getRelationsParam()
68 * @uses PMA_backquote()
69 * @uses PMA_sqlAddslashes()
70 * @uses PMA_query_as_controluser()
71 * @param string $db
72 * @param string $table
74 function PMA_relationsCleanupTable($db, $table)
76 $cfgRelation = PMA_getRelationsParam();
78 if ($cfgRelation['commwork']) {
79 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info'])
80 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
81 . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
82 PMA_query_as_controluser($remove_query);
85 if ($cfgRelation['displaywork']) {
86 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['table_info'])
87 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
88 . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
89 PMA_query_as_controluser($remove_query);
92 if ($cfgRelation['pdfwork']) {
93 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
94 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
95 . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
96 PMA_query_as_controluser($remove_query);
99 if ($cfgRelation['designerwork']) {
100 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['designer_coords'])
101 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
102 . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
103 PMA_query_as_controluser($remove_query);
106 if ($cfgRelation['relwork']) {
107 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['relation'])
108 . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\''
109 . ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\'';
110 PMA_query_as_controluser($remove_query);
112 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['relation'])
113 . ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\''
114 . ' AND foreign_table = \'' . PMA_sqlAddslashes($table) . '\'';
115 PMA_query_as_controluser($remove_query);
120 * Cleanup database related relation stuff
122 * @uses PMA_getRelationsParam()
123 * @uses PMA_backquote()
124 * @uses PMA_sqlAddslashes()
125 * @uses PMA_query_as_controluser()
126 * @param string $db
128 function PMA_relationsCleanupDatabase($db)
130 $cfgRelation = PMA_getRelationsParam();
132 if ($cfgRelation['commwork']) {
133 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info'])
134 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
135 PMA_query_as_controluser($remove_query);
138 if ($cfgRelation['bookmarkwork']) {
139 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['bookmark'])
140 . ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\'';
141 PMA_query_as_controluser($remove_query);
144 if ($cfgRelation['displaywork']) {
145 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['table_info'])
146 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
147 PMA_query_as_controluser($remove_query);
150 if ($cfgRelation['pdfwork']) {
151 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages'])
152 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
153 PMA_query_as_controluser($remove_query);
155 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
156 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
157 PMA_query_as_controluser($remove_query);
160 if ($cfgRelation['designerwork']) {
161 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['designer_coords'])
162 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
163 PMA_query_as_controluser($remove_query);
166 if ($cfgRelation['relwork']) {
167 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['relation'])
168 . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\'';
169 PMA_query_as_controluser($remove_query);
171 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['relation'])
172 . ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\'';
173 PMA_query_as_controluser($remove_query);