fix coding style: true is lower case
[phpmyadmin.git] / pmd_relation_upd.php
blob9dff0579b824a709272067165a1ff1fd8eba83a5
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * PMD relation update handler
6 * @package PhpMyAdmin-Designer
7 */
9 /**
12 require_once './libraries/common.inc.php';
14 PMA_Response::getInstance()->disable();
16 require_once 'libraries/pmd_common.php';
17 extract($_POST, EXTR_SKIP);
18 extract($_GET, EXTR_SKIP);
19 $die_save_pos = 0;
20 require_once 'pmd_save_pos.php';
21 list($DB1, $T1) = explode(".", $T1);
22 list($DB2, $T2) = explode(".", $T2);
24 $tables = $GLOBALS['dbi']->getTablesFull($db, $T1);
25 $type_T1 = strtoupper($tables[$T1]['ENGINE']);
26 $tables = $GLOBALS['dbi']->getTablesFull($db, $T2);
27 $type_T2 = strtoupper($tables[$T2]['ENGINE']);
29 $try_to_delete_internal_relation = false;
31 if (PMA_Util::isForeignKeySupported($type_T1)
32 && PMA_Util::isForeignKeySupported($type_T2)
33 && $type_T1 == $type_T2
34 ) {
35 // InnoDB
36 $existrel_foreign = PMA_getForeigners($DB2, $T2, '', 'foreign');
38 if (isset($existrel_foreign[$F2]['constraint'])) {
39 $upd_query = 'ALTER TABLE ' . PMA_Util::backquote($DB2)
40 . '.' . PMA_Util::backquote($T2) . ' DROP FOREIGN KEY '
41 . PMA_Util::backquote($existrel_foreign[$F2]['constraint'])
42 . ';';
43 $upd_rs = $GLOBALS['dbi']->query($upd_query);
44 } else {
45 // there can be an internal relation even if InnoDB
46 $try_to_delete_internal_relation = true;
48 } else {
49 $try_to_delete_internal_relation = true;
51 if ($try_to_delete_internal_relation) {
52 // internal relations
53 PMA_queryAsControlUser(
54 'DELETE FROM '
55 . PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . '.'
56 . $cfg['Server']['relation'].' WHERE '
57 . 'master_db = \'' . PMA_Util::sqlAddSlashes($DB2) . '\''
58 . ' AND master_table = \'' . PMA_Util::sqlAddSlashes($T2) . '\''
59 . ' AND master_field = \'' . PMA_Util::sqlAddSlashes($F2) . '\''
60 . ' AND foreign_db = \'' . PMA_Util::sqlAddSlashes($DB1) . '\''
61 . ' AND foreign_table = \'' . PMA_Util::sqlAddSlashes($T1) . '\''
62 . ' AND foreign_field = \'' . PMA_Util::sqlAddSlashes($F1) . '\'',
63 false,
64 PMA_DatabaseInterface::QUERY_STORE
67 PMD_return_upd(1, __('Relation deleted'));