Initial import.
[openemr.git] / interface / main / myadmin / libraries / relation_cleanup.lib.php
blob8c9d3105c78d6336d35ea2a03b3663bca1343579
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
5 /**
6 * Set of functions used for cleaning up phpMyAdmin tables
7 */
10 require_once('./libraries/relation.lib.php');
11 $cfgRelation = PMA_getRelationsParam();
13 function PMA_relationsCleanupColumn($db, $table, $column) {
14 global $cfgRelation;
15 if ($cfgRelation['commwork']) {
16 $remove_query = 'DELETE FROM ' . 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($rmv_query);
24 if ($cfgRelation['displaywork']) {
25 $remove_query = 'DELETE FROM ' . 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($rmv_query);
33 if ($cfgRelation['relwork']) {
34 $remove_query = 'DELETE FROM ' . 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($rmv_query);
41 $remove_query = 'DELETE FROM ' . 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($rmv_query);
50 function PMA_relationsCleanupTable($db, $table) {
51 global $cfgRelation;
53 if ($cfgRelation['commwork']) {
54 $remove_query = 'DELETE FROM ' . 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($rmv_query);
61 if ($cfgRelation['displaywork']) {
62 $remove_query = 'DELETE FROM ' . 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($rmv_query);
69 if ($cfgRelation['pdfwork']) {
70 $remove_query = 'DELETE FROM ' . 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($rmv_query);
77 if ($cfgRelation['relwork']) {
78 $remove_query = 'DELETE FROM ' . 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($rmv_query);
84 $remove_query = 'DELETE FROM ' . 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($rmv_query);
92 function PMA_relationsCleanupDatabase($db) {
93 global $cfgRelation;
95 if ($cfgRelation['commwork']) {
96 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['column_info'])
97 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
98 $rmv_rs = PMA_query_as_cu($remove_query);
99 unset($rmv_query);
102 if ($cfgRelation['bookmarkwork']) {
103 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['bookmark'])
104 . ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\'';
105 $rmv_rs = PMA_query_as_cu($remove_query);
106 unset($rmv_query);
109 if ($cfgRelation['displaywork']) {
110 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['table_info'])
111 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
112 $rmv_rs = PMA_query_as_cu($remove_query);
113 unset($rmv_query);
116 if ($cfgRelation['pdfwork']) {
117 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['pdf_pages'])
118 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
119 $rmv_rs = PMA_query_as_cu($remove_query);
120 unset($rmv_query);
122 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['table_coords'])
123 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
124 $rmv_rs = PMA_query_as_cu($remove_query);
125 unset($rmv_query);
128 if ($cfgRelation['relwork']) {
129 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation'])
130 . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\'';
131 $rmv_rs = PMA_query_as_cu($remove_query);
132 unset($rmv_query);
134 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation'])
135 . ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\'';
136 $rmv_rs = PMA_query_as_cu($remove_query);
137 unset($rmv_query);