Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 77 lines (68 sloc) 2.539 kb
fb9a3a5 Michal Čihař Check before commit!
nijel authored
1 <?php
817e790 synced/fixed vim line
Sebastian Mendel authored
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
374abd5 fixed/added page level docblock
Sebastian Mendel authored
3 /**
4 *
e56949f Michal Čihař Use package name PhpMyAdmin
nijel authored
5 * @package PhpMyAdmin-Designer
374abd5 fixed/added page level docblock
Sebastian Mendel authored
6 */
fb9a3a5 Michal Čihař Check before commit!
nijel authored
7
374abd5 fixed/added page level docblock
Sebastian Mendel authored
8 /**
9 *
10 */
c8b6865 Michal Čihař Move common includes to root files rather than to library (which should ...
nijel authored
11 require_once './libraries/common.inc.php';
31c8ca6 Rouslan Placella Disable Response class for XHR requests in PMD
roccivic authored
12
13 PMA_Response::getInstance()->disable();
7664661 Chanaka Indrajith Dharmarathna Implement class behavior of common.lib.php file
Chanaka authored
14 $common_functions = PMA_CommonFunctions::getInstance();
31c8ca6 Rouslan Placella Disable Response class for XHR requests in PMD
roccivic authored
15
b2fd866 Leading ./ paths for includes can be omitted, part 2
Jo Michael authored
16 require_once 'libraries/pmd_common.php';
11fe557 Marc Delisle avoid of existing variables during extract
lem9 authored
17 extract($_POST, EXTR_SKIP);
18 extract($_GET, EXTR_SKIP);
fb9a3a5 Michal Čihař Check before commit!
nijel authored
19 $die_save_pos = 0;
a30554b Dieter Adriaenssens use require() instead of include() when including file unconditionally
ruleant authored
20 require_once 'pmd_save_pos.php';
e67a0a2 Madhura Jayaratne Spaces between parameters in function calls
madhuracj authored
21 list($DB1, $T1) = explode(".", $T1);
22 list($DB2, $T2) = explode(".", $T2);
fb9a3a5 Michal Čihař Check before commit!
nijel authored
23
24 $tables = PMA_DBI_get_tables_full($db, $T1);
25 $type_T1 = strtoupper($tables[$T1]['ENGINE']);
26 $tables = PMA_DBI_get_tables_full($db, $T2);
27 $type_T2 = strtoupper($tables[$T2]['ENGINE']);
28
8505569 Marc Delisle Designer: their could be an internal relation to delete even if engine i...
lem9 authored
29 $try_to_delete_internal_relation = false;
30
7664661 Chanaka Indrajith Dharmarathna Implement class behavior of common.lib.php file
Chanaka authored
31 if ($common_functions->isForeignKeySupported($type_T1)
32 && $common_functions->isForeignKeySupported($type_T2)
33 && $type_T1 == $type_T2
34 ) {
9949e5c Marc Delisle Do not try to delete an internal relation if we just deleted an InnoDB o...
lem9 authored
35 // InnoDB
7c5d5c4 Marc Delisle PBXT: foreign key support
lem9 authored
36 $existrel_foreign = PMA_getForeigners($DB2, $T2, '', 'foreign');
fb9a3a5 Michal Čihař Check before commit!
nijel authored
37
7c5d5c4 Marc Delisle PBXT: foreign key support
lem9 authored
38 if (isset($existrel_foreign[$F2]['constraint'])) {
7664661 Chanaka Indrajith Dharmarathna Implement class behavior of common.lib.php file
Chanaka authored
39 $upd_query = 'ALTER TABLE ' . $common_functions->backquote($DB2)
40 . '.' . $common_functions->backquote($T2) . ' DROP FOREIGN KEY '
41 . $common_functions->backquote($existrel_foreign[$F2]['constraint'])
03cb361 Michal Čihař Add trailing ; after ALTER TABLE (rfe #2009500)
nijel authored
42 . ';';
fb9a3a5 Michal Čihař Check before commit!
nijel authored
43 $upd_rs = PMA_DBI_query($upd_query);
8505569 Marc Delisle Designer: their could be an internal relation to delete even if engine i...
lem9 authored
44 } else {
45 // there can be an internal relation even if InnoDB
46 $try_to_delete_internal_relation = true;
fb9a3a5 Michal Čihař Check before commit!
nijel authored
47 }
9949e5c Marc Delisle Do not try to delete an internal relation if we just deleted an InnoDB o...
lem9 authored
48 } else {
8505569 Marc Delisle Designer: their could be an internal relation to delete even if engine i...
lem9 authored
49 $try_to_delete_internal_relation = true;
50 }
51 if ($try_to_delete_internal_relation) {
9949e5c Marc Delisle Do not try to delete an internal relation if we just deleted an InnoDB o...
lem9 authored
52 // internal relations
299da6d Madhura Jayaratne More style errors fixed
madhuracj authored
53 PMA_query_as_controluser(
54 'DELETE FROM '
7664661 Chanaka Indrajith Dharmarathna Implement class behavior of common.lib.php file
Chanaka authored
55 . $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.'
299da6d Madhura Jayaratne More style errors fixed
madhuracj authored
56 . $cfg['Server']['relation'].' WHERE '
7664661 Chanaka Indrajith Dharmarathna Implement class behavior of common.lib.php file
Chanaka authored
57 . 'master_db = \'' . $common_functions->sqlAddSlashes($DB2) . '\''
58 . ' AND master_table = \'' . $common_functions->sqlAddSlashes($T2) . '\''
59 . ' AND master_field = \'' . $common_functions->sqlAddSlashes($F2) . '\''
60 . ' AND foreign_db = \'' . $common_functions->sqlAddSlashes($DB1) . '\''
61 . ' AND foreign_table = \'' . $common_functions->sqlAddSlashes($T1) . '\''
62 . ' AND foreign_field = \'' . $common_functions->sqlAddSlashes($F1) . '\'',
299da6d Madhura Jayaratne More style errors fixed
madhuracj authored
63 false,
64 PMA_DBI_QUERY_STORE
65 );
9949e5c Marc Delisle Do not try to delete an internal relation if we just deleted an InnoDB o...
lem9 authored
66 }
b05a903 Marc Delisle gettext conversion
lem9 authored
67 PMD_return_upd(1, __('Relation deleted'));
fb9a3a5 Michal Čihař Check before commit!
nijel authored
68
e67a0a2 Madhura Jayaratne Spaces between parameters in function calls
madhuracj authored
69 function PMD_return_upd($b, $ret)
fb9a3a5 Michal Čihař Check before commit!
nijel authored
70 {
299da6d Madhura Jayaratne More style errors fixed
madhuracj authored
71 global $K;
72 header("Content-Type: text/xml; charset=utf-8");
73 header("Cache-Control: no-cache");
74 die('<root act="relation_upd" return="'.$ret.'" b="'.$b.'" K="'.$K.'"></root>');
fb9a3a5 Michal Čihař Check before commit!
nijel authored
75 }
76 ?>
Something went wrong with that request. Please try again.