Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 59 lines (53 sloc) 1.957 kb
905f966 @lem9 new
lem9 authored
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 *
5 * @version $Id$
6 * @package phpMyAdmin-Designer
7 */
8
9 /**
10 *
11 */
12 include_once 'pmd_common.php';
13 require_once './libraries/relation.lib.php';
14 extract($_POST, EXTR_SKIP);
15 extract($_GET, EXTR_SKIP);
16 $die_save_pos = 0;
17 include_once 'pmd_save_pos.php';
18 list($DB1,$T1) = explode(".",$T1);
19 list($DB2,$T2) = explode(".",$T2);
20
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']);
25
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');
29
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 }
36 } else {
37 // internal relations
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);
48 }
49 PMD_return(1, 'strRelationDeleted');
50
51 function PMD_return($b,$ret)
52 {
53 global $K;
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>');
57 }
58 ?>
Something went wrong with that request. Please try again.