From 1142f3cbedbe5faf262467d8e40b37f3d54f190a Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Thu, 17 Jun 2004 11:13:14 +0000 Subject: [PATCH] enable Relation view for InnoDB even if the internal infrastructure is not available --- tbl_properties_structure.php | 5 +- tbl_relation.php | 170 +++++++++++++++++++---------------- 2 files changed, 95 insertions(+), 80 deletions(-) diff --git a/tbl_properties_structure.php b/tbl_properties_structure.php index 7b07d083c..5d9356e5f 100644 --- a/tbl_properties_structure.php +++ b/tbl_properties_structure.php @@ -450,7 +450,10 @@ if ($cfg['PropertiesIconic']) { ?>   $foreign_string) { - if ($foreign_string != 'nix') { - list($foreign_db, $foreign_table, $foreign_field) = explode('.', $foreign_string); - if (!isset($existrel[$master_field])) { - $upd_query = 'INSERT INTO ' . PMA_backquote($cfgRelation['relation']) - . '(master_db, master_table, master_field, foreign_db, foreign_table, foreign_field)' - . ' values(' - . '\'' . PMA_sqlAddslashes($db) . '\', ' - . '\'' . PMA_sqlAddslashes($table) . '\', ' - . '\'' . PMA_sqlAddslashes($master_field) . '\', ' - . '\'' . PMA_sqlAddslashes($foreign_db) . '\', ' - . '\'' . PMA_sqlAddslashes($foreign_table) . '\',' - . '\'' . PMA_sqlAddslashes($foreign_field) . '\')'; - } else if ($existrel[$master_field]['foreign_db'] . '.' .$existrel[$master_field]['foreign_table'] . '.' . $existrel[$master_field]['foreign_field'] != $foreign_string) { - $upd_query = 'UPDATE ' . PMA_backquote($cfgRelation['relation']) . ' SET' - . ' foreign_db = \'' . PMA_sqlAddslashes($foreign_db) . '\', ' - . ' foreign_table = \'' . PMA_sqlAddslashes($foreign_table) . '\', ' - . ' foreign_field = \'' . PMA_sqlAddslashes($foreign_field) . '\' ' - . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\'' - . ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\'' - . ' AND master_field = \'' . PMA_sqlAddslashes($master_field) . '\''; + foreach ($destination AS $master_field => $foreign_string) { + if ($foreign_string != 'nix') { + list($foreign_db, $foreign_table, $foreign_field) = explode('.', $foreign_string); + if (!isset($existrel[$master_field])) { + $upd_query = 'INSERT INTO ' . PMA_backquote($cfgRelation['relation']) + . '(master_db, master_table, master_field, foreign_db, foreign_table, foreign_field)' + . ' values(' + . '\'' . PMA_sqlAddslashes($db) . '\', ' + . '\'' . PMA_sqlAddslashes($table) . '\', ' + . '\'' . PMA_sqlAddslashes($master_field) . '\', ' + . '\'' . PMA_sqlAddslashes($foreign_db) . '\', ' + . '\'' . PMA_sqlAddslashes($foreign_table) . '\',' + . '\'' . PMA_sqlAddslashes($foreign_field) . '\')'; + } else if ($existrel[$master_field]['foreign_db'] . '.' .$existrel[$master_field]['foreign_table'] . '.' . $existrel[$master_field]['foreign_field'] != $foreign_string) { + $upd_query = 'UPDATE ' . PMA_backquote($cfgRelation['relation']) . ' SET' + . ' foreign_db = \'' . PMA_sqlAddslashes($foreign_db) . '\', ' + . ' foreign_table = \'' . PMA_sqlAddslashes($foreign_table) . '\', ' + . ' foreign_field = \'' . PMA_sqlAddslashes($foreign_field) . '\' ' + . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\'' + . ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\'' + . ' AND master_field = \'' . PMA_sqlAddslashes($master_field) . '\''; + } // end if... else.... + } else if (isset($existrel[$master_field])) { + $upd_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation']) + . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\'' + . ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\'' + . ' AND master_field = \'' . PMA_sqlAddslashes($master_field) . '\''; } // end if... else.... - } else if (isset($existrel[$master_field])) { - $upd_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation']) - . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\'' - . ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\'' - . ' AND master_field = \'' . PMA_sqlAddslashes($master_field) . '\''; - } // end if... else.... - if (isset($upd_query)) { - $upd_rs = PMA_query_as_cu($upd_query); - unset($upd_query); - } - } // end while - + if (isset($upd_query)) { + $upd_rs = PMA_query_as_cu($upd_query); + unset($upd_query); + } + } // end while + } // end if (updates for internal relations) // u p d a t e s f o r I n n o D B - // ( for now, one index name; we keep the definitions if the + // ( for now, one index name only; we keep the definitions if the // foreign db is not the same) if (isset($destination_innodb)) { foreach ($destination_innodb AS $master_field => $foreign_string) { @@ -197,7 +198,7 @@ if ($cfgRelation['relwork'] } // end while } // end if isset($destination_innodb) -} // end if +} // end if (updates for internal relations or InnoDB) // U p d a t e s f o r d i s p l a y f i e l d @@ -239,9 +240,10 @@ if ($cfgRelation['commwork'] } // end if (commwork) // If we did an update, refresh our data -if ($cfgRelation['relwork'] - && isset($submit_rel) && $submit_rel == 'true') { - $existrel = PMA_getForeigners($db, $table, '', 'internal'); +if (isset($submit_rel) && $submit_rel == 'true') { + if ($cfgRelation['relwork']) { + $existrel = PMA_getForeigners($db, $table, '', 'internal'); + } if ($tbl_type=='INNODB') { $existrel_innodb = PMA_getForeigners($db, $table, '', 'innodb'); } @@ -257,7 +259,7 @@ if ($cfgRelation['commwork']) { /** * Dialog */ -if ($cfgRelation['relwork']) { +if ($cfgRelation['relwork'] || $tbl_type=='INNODB') { // To choose relations we first need all tables names in current db // and if PMA version permits and the main table is innodb, @@ -360,12 +362,15 @@ if ($col_rs && PMA_DBI_num_rows($col_rs) > 0) { - + ' .$strInternalRelations; + if ($tbl_type=='INNODB') { + echo ' (*)'; + } + echo ''; + } if ($tbl_type=='INNODB') { echo 'InnoDB'; if (PMA_MYSQL_INT_VERSION < 40013) { @@ -382,43 +387,48 @@ if ($col_rs && PMA_DBI_num_rows($col_rs) > 0) { ?> + @@ -486,10 +496,12 @@ if ($col_rs && PMA_DBI_num_rows($col_rs) > 0) { '; - if (PMA_MYSQL_INT_VERSION < 40013) { - echo '** ' . sprintf($strUpgrade, 'MySQL', '4.0.13') . '
'; - } + if ($cfgRelation['relwork']) { + echo $strInternalNotNecessary . '
'; + } + if (PMA_MYSQL_INT_VERSION < 40013) { + echo '** ' . sprintf($strUpgrade, 'MySQL', '4.0.13') . '
'; + } } ?>