Fix for 3299241. Updated style for "disabled" topnav buttons.
[phpmyadmin/ammaryasirr.git] / pmd_relation_upd.php
blob564395b1acbdcaa5f6ebc8d1e622950ccc7617e9
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @package phpMyAdmin-Designer
6 */
8 /**
11 include_once 'pmd_common.php';
12 extract($_POST, EXTR_SKIP);
13 extract($_GET, EXTR_SKIP);
14 $die_save_pos = 0;
15 include_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) {
27 // InnoDB
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);
35 } else {
36 // there can be an internal relation even if InnoDB
37 $try_to_delete_internal_relation = true;
39 } else {
40 $try_to_delete_internal_relation = true;
42 if ($try_to_delete_internal_relation) {
43 // internal relations
44 PMA_query_as_controluser('DELETE FROM '
45 . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
46 . $cfg['Server']['relation'].' WHERE '
47 . 'master_db = \'' . PMA_sqlAddslashes($DB2) . '\''
48 . ' AND master_table = \'' . PMA_sqlAddslashes($T2) . '\''
49 . ' AND master_field = \'' . PMA_sqlAddslashes($F2) . '\''
50 . ' AND foreign_db = \'' . PMA_sqlAddslashes($DB1) . '\''
51 . ' AND foreign_table = \'' . PMA_sqlAddslashes($T1) . '\''
52 . ' AND foreign_field = \'' . PMA_sqlAddslashes($F1) . '\''
53 , FALSE, PMA_DBI_QUERY_STORE);
55 PMD_return_upd(1, __('Relation deleted'));
57 function PMD_return_upd($b,$ret)
59 global $K;
60 header("Content-Type: text/xml; charset=utf-8");
61 header("Cache-Control: no-cache");
62 die('<root act="relation_upd" return="'.$ret.'" b="'.$b.'" K="'.$K.'"></root>');