Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 65 lines (58 sloc) 2.165 kb
fb9a3a5 @nijel Check before commit!
nijel authored
1 <?php
817e790 synced/fixed vim line
Sebastian Mendel authored
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
374abd5 fixed/added page level docblock
Sebastian Mendel authored
3 /**
4 *
da19f7b marked phpMyAdmin Designer as own package (phpMyAdmin-Designer)
Sebastian Mendel authored
5 * @package phpMyAdmin-Designer
374abd5 fixed/added page level docblock
Sebastian Mendel authored
6 */
fb9a3a5 @nijel Check before commit!
nijel authored
7
374abd5 fixed/added page level docblock
Sebastian Mendel authored
8 /**
9 *
10 */
2139841 @lem9 rename pmd_session.php to pmd_common.php
lem9 authored
11 include_once 'pmd_common.php';
11fe557 @lem9 avoid of existing variables during extract
lem9 authored
12 extract($_POST, EXTR_SKIP);
13 extract($_GET, EXTR_SKIP);
fb9a3a5 @nijel Check before commit!
nijel authored
14 $die_save_pos = 0;
15 include_once 'pmd_save_pos.php';
16 list($DB1,$T1) = explode(".",$T1);
17 list($DB2,$T2) = explode(".",$T2);
18
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']);
23
8505569 @lem9 Designer: their could be an internal relation to delete even if engine i...
lem9 authored
24 $try_to_delete_internal_relation = false;
25
7c5d5c4 @lem9 PBXT: foreign key support
lem9 authored
26 if (PMA_foreignkey_supported($type_T1) && PMA_foreignkey_supported($type_T2) && $type_T1 == $type_T2) {
9949e5c @lem9 Do not try to delete an internal relation if we just deleted an InnoDB o...
lem9 authored
27 // InnoDB
7c5d5c4 @lem9 PBXT: foreign key support
lem9 authored
28 $existrel_foreign = PMA_getForeigners($DB2, $T2, '', 'foreign');
fb9a3a5 @nijel Check before commit!
nijel authored
29
7c5d5c4 @lem9 PBXT: foreign key support
lem9 authored
30 if (isset($existrel_foreign[$F2]['constraint'])) {
fb9a3a5 @nijel Check before commit!
nijel authored
31 $upd_query = 'ALTER TABLE ' . PMA_backquote($T2)
32 . ' DROP FOREIGN KEY '
7c5d5c4 @lem9 PBXT: foreign key support
lem9 authored
33 . PMA_backquote($existrel_foreign[$F2]['constraint']);
fb9a3a5 @nijel Check before commit!
nijel authored
34 $upd_rs = PMA_DBI_query($upd_query);
8505569 @lem9 Designer: their could be an internal relation to delete even if engine i...
lem9 authored
35 } else {
36 // there can be an internal relation even if InnoDB
37 $try_to_delete_internal_relation = true;
fb9a3a5 @nijel Check before commit!
nijel authored
38 }
9949e5c @lem9 Do not try to delete an internal relation if we just deleted an InnoDB o...
lem9 authored
39 } else {
8505569 @lem9 Designer: their could be an internal relation to delete even if engine i...
lem9 authored
40 $try_to_delete_internal_relation = true;
41 }
42 if ($try_to_delete_internal_relation) {
9949e5c @lem9 Do not try to delete an internal relation if we just deleted an InnoDB o...
lem9 authored
43 // internal relations
e67f4cb @lem9 clarify function name
lem9 authored
44 PMA_query_as_controluser('DELETE FROM '
dc6c010 @lem9 deleting internal relation no longer worked
lem9 authored
45 . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
46 . $cfg['Server']['relation'].' WHERE '
817e790 synced/fixed vim line
Sebastian Mendel authored
47 . 'master_db = \'' . PMA_sqlAddslashes($DB2) . '\''
dc6c010 @lem9 deleting internal relation no longer worked
lem9 authored
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) . '\''
af31d1e @lem9 designer: support for MSIE 6 and various fixes
lem9 authored
53 , FALSE, PMA_DBI_QUERY_STORE);
9949e5c @lem9 Do not try to delete an internal relation if we just deleted an InnoDB o...
lem9 authored
54 }
b05a903 @lem9 gettext conversion
lem9 authored
55 PMD_return_upd(1, __('Relation deleted'));
fb9a3a5 @nijel Check before commit!
nijel authored
56
c892873 @nijel Do not use same function name in two contexts.
nijel authored
57 function PMD_return_upd($b,$ret)
fb9a3a5 @nijel Check before commit!
nijel authored
58 {
59 global $K;
af31d1e @lem9 designer: support for MSIE 6 and various fixes
lem9 authored
60 header("Content-Type: text/xml; charset=utf-8");
61 header("Cache-Control: no-cache");
fb9a3a5 @nijel Check before commit!
nijel authored
62 die('<root act="relation_upd" return="'.$ret.'" b="'.$b.'" K="'.$K.'"></root>');
63 }
64 ?>
Something went wrong with that request. Please try again.