Translation update done using Pootle.
[phpmyadmin.git] / libraries / relation_cleanup.lib.php
blob3546fbbd119aaa2f0ad17f0544a6db2005d1f0e4
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Set of functions used for cleaning up phpMyAdmin tables
6 * @package phpMyAdmin
7 */
8 if (! defined('PHPMYADMIN')) {
9 exit;
12 /**
13 * Cleanu column related relation stuff
15 * @param string $db
16 * @param string $table
17 * @param string $column
19 function PMA_relationsCleanupColumn($db, $table, $column)
21 $cfgRelation = PMA_getRelationsParam();
23 if ($cfgRelation['commwork']) {
24 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info'])
25 . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
26 . ' AND table_name = \'' . PMA_sqlAddSlashes($table) . '\''
27 . ' AND column_name = \'' . PMA_sqlAddSlashes($column) . '\'';
28 PMA_query_as_controluser($remove_query);
31 if ($cfgRelation['displaywork']) {
32 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['table_info'])
33 . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
34 . ' AND table_name = \'' . PMA_sqlAddSlashes($table) . '\''
35 . ' AND display_field = \'' . PMA_sqlAddSlashes($column) . '\'';
36 PMA_query_as_controluser($remove_query);
39 if ($cfgRelation['relwork']) {
40 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['relation'])
41 . ' WHERE master_db = \'' . PMA_sqlAddSlashes($db) . '\''
42 . ' AND master_table = \'' . PMA_sqlAddSlashes($table) . '\''
43 . ' AND master_field = \'' . PMA_sqlAddSlashes($column) . '\'';
44 PMA_query_as_controluser($remove_query);
46 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['relation'])
47 . ' WHERE foreign_db = \'' . PMA_sqlAddSlashes($db) . '\''
48 . ' AND foreign_table = \'' . PMA_sqlAddSlashes($table) . '\''
49 . ' AND foreign_field = \'' . PMA_sqlAddSlashes($column) . '\'';
50 PMA_query_as_controluser($remove_query);
54 /**
55 * Cleanup table related relation stuff
57 * @param string $db
58 * @param string $table
60 function PMA_relationsCleanupTable($db, $table)
62 $cfgRelation = PMA_getRelationsParam();
64 if ($cfgRelation['commwork']) {
65 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info'])
66 . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
67 . ' AND table_name = \'' . PMA_sqlAddSlashes($table) . '\'';
68 PMA_query_as_controluser($remove_query);
71 if ($cfgRelation['displaywork']) {
72 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['table_info'])
73 . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
74 . ' AND table_name = \'' . PMA_sqlAddSlashes($table) . '\'';
75 PMA_query_as_controluser($remove_query);
78 if ($cfgRelation['pdfwork']) {
79 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
80 . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
81 . ' AND table_name = \'' . PMA_sqlAddSlashes($table) . '\'';
82 PMA_query_as_controluser($remove_query);
85 if ($cfgRelation['designerwork']) {
86 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['designer_coords'])
87 . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
88 . ' AND table_name = \'' . PMA_sqlAddSlashes($table) . '\'';
89 PMA_query_as_controluser($remove_query);
92 if ($cfgRelation['relwork']) {
93 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['relation'])
94 . ' WHERE master_db = \'' . PMA_sqlAddSlashes($db) . '\''
95 . ' AND master_table = \'' . PMA_sqlAddSlashes($table) . '\'';
96 PMA_query_as_controluser($remove_query);
98 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['relation'])
99 . ' WHERE foreign_db = \'' . PMA_sqlAddSlashes($db) . '\''
100 . ' AND foreign_table = \'' . PMA_sqlAddSlashes($table) . '\'';
101 PMA_query_as_controluser($remove_query);
106 * Cleanup database related relation stuff
108 * @param string $db
110 function PMA_relationsCleanupDatabase($db)
112 $cfgRelation = PMA_getRelationsParam();
114 if ($cfgRelation['commwork']) {
115 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info'])
116 . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'';
117 PMA_query_as_controluser($remove_query);
120 if ($cfgRelation['bookmarkwork']) {
121 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['bookmark'])
122 . ' WHERE dbase = \'' . PMA_sqlAddSlashes($db) . '\'';
123 PMA_query_as_controluser($remove_query);
126 if ($cfgRelation['displaywork']) {
127 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['table_info'])
128 . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'';
129 PMA_query_as_controluser($remove_query);
132 if ($cfgRelation['pdfwork']) {
133 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages'])
134 . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'';
135 PMA_query_as_controluser($remove_query);
137 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
138 . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'';
139 PMA_query_as_controluser($remove_query);
142 if ($cfgRelation['designerwork']) {
143 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['designer_coords'])
144 . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'';
145 PMA_query_as_controluser($remove_query);
148 if ($cfgRelation['relwork']) {
149 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['relation'])
150 . ' WHERE master_db = \'' . PMA_sqlAddSlashes($db) . '\'';
151 PMA_query_as_controluser($remove_query);
153 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['relation'])
154 . ' WHERE foreign_db = \'' . PMA_sqlAddSlashes($db) . '\'';
155 PMA_query_as_controluser($remove_query);