Translation update done using Pootle.
[phpmyadmin.git] / pmd_relation_upd.php
blob24ced45192160c527d0a57de01bdb0a2b2787702
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @package PhpMyAdmin-Designer
6 */
8 /**
11 require_once './libraries/pmd_common.php';
12 extract($_POST, EXTR_SKIP);
13 extract($_GET, EXTR_SKIP);
14 $die_save_pos = 0;
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) {
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(
45 'DELETE FROM '
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) . '\'',
54 false,
55 PMA_DBI_QUERY_STORE
58 PMD_return_upd(1, __('Relation deleted'));
60 function PMD_return_upd($b, $ret)
62 global $K;
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>');