2 /* vim: set expandtab sw=4 ts=4 sts=4: */
5 * @package PhpMyAdmin-Designer
11 require_once './libraries/pmd_common.php';
12 extract($_POST, EXTR_SKIP
);
13 extract($_GET, EXTR_SKIP
);
15 require_once 'pmd_save_pos.php';
16 list($DB1, $T1) = explode(".", $T1);
17 list($DB2, $T2) = explode(".", $T2);
19 $tables = PMA_DBI_get_tables_full($db, $T1);
20 $type_T1 = strtoupper($tables[$T1]['ENGINE']);
21 $tables = PMA_DBI_get_tables_full($db, $T2);
22 $type_T2 = strtoupper($tables[$T2]['ENGINE']);
24 $try_to_delete_internal_relation = false;
26 if (PMA_foreignkey_supported($type_T1) && PMA_foreignkey_supported($type_T2) && $type_T1 == $type_T2) {
28 $existrel_foreign = PMA_getForeigners($DB2, $T2, '', 'foreign');
30 if (isset($existrel_foreign[$F2]['constraint'])) {
31 $upd_query = 'ALTER TABLE ' . PMA_backquote($T2)
32 . ' DROP FOREIGN KEY '
33 . PMA_backquote($existrel_foreign[$F2]['constraint']);
34 $upd_rs = PMA_DBI_query($upd_query);
36 // there can be an internal relation even if InnoDB
37 $try_to_delete_internal_relation = true;
40 $try_to_delete_internal_relation = true;
42 if ($try_to_delete_internal_relation) {
44 PMA_query_as_controluser(
46 . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
47 . $cfg['Server']['relation'].' WHERE '
48 . 'master_db = \'' . PMA_sqlAddSlashes($DB2) . '\''
49 . ' AND master_table = \'' . PMA_sqlAddSlashes($T2) . '\''
50 . ' AND master_field = \'' . PMA_sqlAddSlashes($F2) . '\''
51 . ' AND foreign_db = \'' . PMA_sqlAddSlashes($DB1) . '\''
52 . ' AND foreign_table = \'' . PMA_sqlAddSlashes($T1) . '\''
53 . ' AND foreign_field = \'' . PMA_sqlAddSlashes($F1) . '\'',
58 PMD_return_upd(1, __('Relation deleted'));
60 function PMD_return_upd($b, $ret)
63 header("Content-Type: text/xml; charset=utf-8");
64 header("Cache-Control: no-cache");
65 die('<root act="relation_upd" return="'.$ret.'" b="'.$b.'" K="'.$K.'"></root>');