Merge branch 'MAINT_3_3_5'
[phpmyadmin/crack.git] / pmd_relation_upd.php
bloba4ee7f93820f5f246f7c379248ac5f2077876f29
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 require_once './libraries/relation.lib.php';
13 extract($_POST, EXTR_SKIP);
14 extract($_GET, EXTR_SKIP);
15 $die_save_pos = 0;
16 include_once 'pmd_save_pos.php';
17 list($DB1,$T1) = explode(".",$T1);
18 list($DB2,$T2) = explode(".",$T2);
20 $tables = PMA_DBI_get_tables_full($db, $T1);
21 $type_T1 = strtoupper($tables[$T1]['ENGINE']);
22 $tables = PMA_DBI_get_tables_full($db, $T2);
23 $type_T2 = strtoupper($tables[$T2]['ENGINE']);
25 if (PMA_foreignkey_supported($type_T1) && PMA_foreignkey_supported($type_T2) && $type_T1 == $type_T2) {
26 // InnoDB
27 $existrel_foreign = PMA_getForeigners($DB2, $T2, '', 'foreign');
29 if (isset($existrel_foreign[$F2]['constraint'])) {
30 $upd_query = 'ALTER TABLE ' . PMA_backquote($T2)
31 . ' DROP FOREIGN KEY '
32 . PMA_backquote($existrel_foreign[$F2]['constraint']);
33 $upd_rs = PMA_DBI_query($upd_query);
35 } else {
36 // internal relations
37 PMA_query_as_controluser('DELETE FROM '
38 . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
39 . $cfg['Server']['relation'].' WHERE '
40 . 'master_db = \'' . PMA_sqlAddslashes($DB2) . '\''
41 . ' AND master_table = \'' . PMA_sqlAddslashes($T2) . '\''
42 . ' AND master_field = \'' . PMA_sqlAddslashes($F2) . '\''
43 . ' AND foreign_db = \'' . PMA_sqlAddslashes($DB1) . '\''
44 . ' AND foreign_table = \'' . PMA_sqlAddslashes($T1) . '\''
45 . ' AND foreign_field = \'' . PMA_sqlAddslashes($F1) . '\''
46 , FALSE, PMA_DBI_QUERY_STORE);
48 PMD_return_upd(1, __('Relation deleted'));
50 function PMD_return_upd($b,$ret)
52 global $K;
53 header("Content-Type: text/xml; charset=utf-8");
54 header("Cache-Control: no-cache");
55 die('<root act="relation_upd" return="'.$ret.'" b="'.$b.'" K="'.$K.'"></root>');