2 /* vim: set expandtab sw=4 ts=4 sts=4: */
6 * @package phpMyAdmin-Designer
12 include_once 'pmd_common.php';
13 require_once './libraries/relation.lib.php';
14 extract($_POST, EXTR_SKIP
);
15 extract($_GET, EXTR_SKIP
);
17 include_once 'pmd_save_pos.php';
18 list($DB1,$T1) = explode(".",$T1);
19 list($DB2,$T2) = explode(".",$T2);
21 $tables = PMA_DBI_get_tables_full($db, $T1);
22 $type_T1 = strtoupper($tables[$T1]['ENGINE']);
23 $tables = PMA_DBI_get_tables_full($db, $T2);
24 $type_T2 = strtoupper($tables[$T2]['ENGINE']);
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);
38 PMA_query_as_cu('DELETE FROM '
39 . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
40 . $cfg['Server']['relation'].' WHERE '
41 . 'master_db = \'' . PMA_sqlAddslashes($DB2) . '\''
42 . ' AND master_table = \'' . PMA_sqlAddslashes($T2) . '\''
43 . ' AND master_field = \'' . PMA_sqlAddslashes($F2) . '\''
44 . ' AND foreign_db = \'' . PMA_sqlAddslashes($DB1) . '\''
45 . ' AND foreign_table = \'' . PMA_sqlAddslashes($T1) . '\''
46 . ' AND foreign_field = \'' . PMA_sqlAddslashes($F1) . '\''
47 , FALSE, PMA_DBI_QUERY_STORE
);
49 PMD_return_upd(1, 'strRelationDeleted');
51 function PMD_return_upd($b,$ret)
54 header("Content-Type: text/xml; charset=utf-8");
55 header("Cache-Control: no-cache");
56 die('<root act="relation_upd" return="'.$ret.'" b="'.$b.'" K="'.$K.'"></root>');