enable Relation view for InnoDB even if the internal infrastructure is not available
This commit is contained in:
@@ -450,7 +450,10 @@ if ($cfg['PropertiesIconic']) {
|
|||||||
?></a>
|
?></a>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if ($cfg['Server']['relation']) {
|
// if internal relations are available, or the table type is INNODB
|
||||||
|
// ($tbl_type comes from tbl_properties_table_info.php)
|
||||||
|
|
||||||
|
if ($cfg['Server']['relation'] || $tbl_type=="INNODB") {
|
||||||
?>
|
?>
|
||||||
<!-- Work on Relations -->
|
<!-- Work on Relations -->
|
||||||
<a href="tbl_relation.php?<?php echo $url_query; ?>"><?php
|
<a href="tbl_relation.php?<?php echo $url_query; ?>"><?php
|
||||||
|
170
tbl_relation.php
170
tbl_relation.php
@@ -12,7 +12,7 @@ $url_query .= '&goto=tbl_properties.php';
|
|||||||
|
|
||||||
// Note: in tbl_properties_table_info we get and display the table comment.
|
// Note: in tbl_properties_table_info we get and display the table comment.
|
||||||
// For InnoDB, this comment contains the REFER information but any update
|
// For InnoDB, this comment contains the REFER information but any update
|
||||||
// has not been done yet (will be done in tbl_relation later).
|
// has not been done yet (will be done in tbl_relation.php later).
|
||||||
$avoid_show_comment = TRUE;
|
$avoid_show_comment = TRUE;
|
||||||
require('./tbl_properties_table_info.php');
|
require('./tbl_properties_table_info.php');
|
||||||
require_once('./libraries/relation.lib.php');
|
require_once('./libraries/relation.lib.php');
|
||||||
@@ -64,55 +64,56 @@ $cfgRelation = PMA_getRelationsParam();
|
|||||||
|
|
||||||
if ($cfgRelation['relwork']) {
|
if ($cfgRelation['relwork']) {
|
||||||
$existrel = PMA_getForeigners($db, $table, '', 'internal');
|
$existrel = PMA_getForeigners($db, $table, '', 'internal');
|
||||||
if ($tbl_type=='INNODB') {
|
}
|
||||||
$existrel_innodb = PMA_getForeigners($db, $table, '', 'innodb');
|
if ($tbl_type=='INNODB') {
|
||||||
}
|
$existrel_innodb = PMA_getForeigners($db, $table, '', 'innodb');
|
||||||
}
|
}
|
||||||
if ($cfgRelation['displaywork']) {
|
if ($cfgRelation['displaywork']) {
|
||||||
$disp = PMA_getDisplayField($db, $table);
|
$disp = PMA_getDisplayField($db, $table);
|
||||||
}
|
}
|
||||||
if ($cfgRelation['relwork']
|
|
||||||
&& isset($submit_rel) && $submit_rel == 'true') {
|
|
||||||
|
|
||||||
|
// updates for internal relations or innodb?
|
||||||
|
if (isset($submit_rel) && $submit_rel == 'true') {
|
||||||
// u p d a t e s f o r I n t e r n a l r e l a t i o n s
|
// u p d a t e s f o r I n t e r n a l r e l a t i o n s
|
||||||
|
if ($cfgRelation['relwork']) {
|
||||||
|
|
||||||
foreach ($destination AS $master_field => $foreign_string) {
|
foreach ($destination AS $master_field => $foreign_string) {
|
||||||
if ($foreign_string != 'nix') {
|
if ($foreign_string != 'nix') {
|
||||||
list($foreign_db, $foreign_table, $foreign_field) = explode('.', $foreign_string);
|
list($foreign_db, $foreign_table, $foreign_field) = explode('.', $foreign_string);
|
||||||
if (!isset($existrel[$master_field])) {
|
if (!isset($existrel[$master_field])) {
|
||||||
$upd_query = 'INSERT INTO ' . PMA_backquote($cfgRelation['relation'])
|
$upd_query = 'INSERT INTO ' . PMA_backquote($cfgRelation['relation'])
|
||||||
. '(master_db, master_table, master_field, foreign_db, foreign_table, foreign_field)'
|
. '(master_db, master_table, master_field, foreign_db, foreign_table, foreign_field)'
|
||||||
. ' values('
|
. ' values('
|
||||||
. '\'' . PMA_sqlAddslashes($db) . '\', '
|
. '\'' . PMA_sqlAddslashes($db) . '\', '
|
||||||
. '\'' . PMA_sqlAddslashes($table) . '\', '
|
. '\'' . PMA_sqlAddslashes($table) . '\', '
|
||||||
. '\'' . PMA_sqlAddslashes($master_field) . '\', '
|
. '\'' . PMA_sqlAddslashes($master_field) . '\', '
|
||||||
. '\'' . PMA_sqlAddslashes($foreign_db) . '\', '
|
. '\'' . PMA_sqlAddslashes($foreign_db) . '\', '
|
||||||
. '\'' . PMA_sqlAddslashes($foreign_table) . '\','
|
. '\'' . PMA_sqlAddslashes($foreign_table) . '\','
|
||||||
. '\'' . PMA_sqlAddslashes($foreign_field) . '\')';
|
. '\'' . PMA_sqlAddslashes($foreign_field) . '\')';
|
||||||
} else if ($existrel[$master_field]['foreign_db'] . '.' .$existrel[$master_field]['foreign_table'] . '.' . $existrel[$master_field]['foreign_field'] != $foreign_string) {
|
} 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'
|
$upd_query = 'UPDATE ' . PMA_backquote($cfgRelation['relation']) . ' SET'
|
||||||
. ' foreign_db = \'' . PMA_sqlAddslashes($foreign_db) . '\', '
|
. ' foreign_db = \'' . PMA_sqlAddslashes($foreign_db) . '\', '
|
||||||
. ' foreign_table = \'' . PMA_sqlAddslashes($foreign_table) . '\', '
|
. ' foreign_table = \'' . PMA_sqlAddslashes($foreign_table) . '\', '
|
||||||
. ' foreign_field = \'' . PMA_sqlAddslashes($foreign_field) . '\' '
|
. ' foreign_field = \'' . PMA_sqlAddslashes($foreign_field) . '\' '
|
||||||
. ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\''
|
. ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\''
|
||||||
. ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\''
|
. ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\''
|
||||||
. ' AND master_field = \'' . PMA_sqlAddslashes($master_field) . '\'';
|
. ' 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....
|
} // end if... else....
|
||||||
} else if (isset($existrel[$master_field])) {
|
if (isset($upd_query)) {
|
||||||
$upd_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation'])
|
$upd_rs = PMA_query_as_cu($upd_query);
|
||||||
. ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\''
|
unset($upd_query);
|
||||||
. ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\''
|
}
|
||||||
. ' AND master_field = \'' . PMA_sqlAddslashes($master_field) . '\'';
|
} // end while
|
||||||
} // end if... else....
|
} // end if (updates for internal relations)
|
||||||
if (isset($upd_query)) {
|
|
||||||
$upd_rs = PMA_query_as_cu($upd_query);
|
|
||||||
unset($upd_query);
|
|
||||||
}
|
|
||||||
} // end while
|
|
||||||
|
|
||||||
|
|
||||||
// u p d a t e s f o r I n n o D B
|
// 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)
|
// foreign db is not the same)
|
||||||
if (isset($destination_innodb)) {
|
if (isset($destination_innodb)) {
|
||||||
foreach ($destination_innodb AS $master_field => $foreign_string) {
|
foreach ($destination_innodb AS $master_field => $foreign_string) {
|
||||||
@@ -197,7 +198,7 @@ if ($cfgRelation['relwork']
|
|||||||
} // end while
|
} // end while
|
||||||
} // end if isset($destination_innodb)
|
} // 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
|
// 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)
|
} // end if (commwork)
|
||||||
|
|
||||||
// If we did an update, refresh our data
|
// If we did an update, refresh our data
|
||||||
if ($cfgRelation['relwork']
|
if (isset($submit_rel) && $submit_rel == 'true') {
|
||||||
&& isset($submit_rel) && $submit_rel == 'true') {
|
if ($cfgRelation['relwork']) {
|
||||||
$existrel = PMA_getForeigners($db, $table, '', 'internal');
|
$existrel = PMA_getForeigners($db, $table, '', 'internal');
|
||||||
|
}
|
||||||
if ($tbl_type=='INNODB') {
|
if ($tbl_type=='INNODB') {
|
||||||
$existrel_innodb = PMA_getForeigners($db, $table, '', 'innodb');
|
$existrel_innodb = PMA_getForeigners($db, $table, '', 'innodb');
|
||||||
}
|
}
|
||||||
@@ -257,7 +259,7 @@ if ($cfgRelation['commwork']) {
|
|||||||
/**
|
/**
|
||||||
* Dialog
|
* Dialog
|
||||||
*/
|
*/
|
||||||
if ($cfgRelation['relwork']) {
|
if ($cfgRelation['relwork'] || $tbl_type=='INNODB') {
|
||||||
|
|
||||||
// To choose relations we first need all tables names in current db
|
// To choose relations we first need all tables names in current db
|
||||||
// and if PMA version permits and the main table is innodb,
|
// 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) {
|
|||||||
<th colspan="<?php echo $tbl_type=='INNODB' ? '4' : '2'; ?>" align="center" class="tblHeaders"><b><?php echo $strLinksTo; ?></b></th>
|
<th colspan="<?php echo $tbl_type=='INNODB' ? '4' : '2'; ?>" align="center" class="tblHeaders"><b><?php echo $strLinksTo; ?></b></th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th></th><th><b><?php echo $strInternalRelations;
|
<th></th>
|
||||||
if ($tbl_type=='INNODB') {
|
|
||||||
echo ' (*)';
|
|
||||||
}
|
|
||||||
?></b></th>
|
|
||||||
<?php
|
<?php
|
||||||
|
if ($cfgRelation['relwork']) {
|
||||||
|
echo ' <th><b>' .$strInternalRelations;
|
||||||
|
if ($tbl_type=='INNODB') {
|
||||||
|
echo ' (*)';
|
||||||
|
}
|
||||||
|
echo '</b></th>';
|
||||||
|
}
|
||||||
if ($tbl_type=='INNODB') {
|
if ($tbl_type=='INNODB') {
|
||||||
echo '<th colspan="2">InnoDB';
|
echo '<th colspan="2">InnoDB';
|
||||||
if (PMA_MYSQL_INT_VERSION < 40013) {
|
if (PMA_MYSQL_INT_VERSION < 40013) {
|
||||||
@@ -382,43 +387,48 @@ if ($col_rs && PMA_DBI_num_rows($col_rs) > 0) {
|
|||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center" bgcolor="<?php echo ($i % 2) ? $GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo']; ?>"><b><?php echo $save_row[$i]['Field']; ?></b></td>
|
<td align="center" bgcolor="<?php echo ($i % 2) ? $GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo']; ?>"><b><?php echo $save_row[$i]['Field']; ?></b></td>
|
||||||
|
<?php
|
||||||
|
if ($cfgRelation['relwork']) {
|
||||||
|
?>
|
||||||
<td bgcolor="<?php echo ($i % 2) ? $GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo']; ?>">
|
<td bgcolor="<?php echo ($i % 2) ? $GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo']; ?>">
|
||||||
<select name="destination[<?php echo htmlspecialchars($save_row[$i]['Field']); ?>]">
|
<select name="destination[<?php echo htmlspecialchars($save_row[$i]['Field']); ?>]">
|
||||||
<?php
|
<?php
|
||||||
echo "\n";
|
echo "\n";
|
||||||
|
|
||||||
// PMA internal relations
|
// PMA internal relations
|
||||||
if (isset($existrel[$myfield])) {
|
if (isset($existrel[$myfield])) {
|
||||||
$foreign_field = $existrel[$myfield]['foreign_db'] . '.'
|
$foreign_field = $existrel[$myfield]['foreign_db'] . '.'
|
||||||
. $existrel[$myfield]['foreign_table'] . '.'
|
. $existrel[$myfield]['foreign_table'] . '.'
|
||||||
. $existrel[$myfield]['foreign_field'];
|
. $existrel[$myfield]['foreign_field'];
|
||||||
} else {
|
} else {
|
||||||
$foreign_field = FALSE;
|
$foreign_field = FALSE;
|
||||||
}
|
|
||||||
$seen_key = FALSE;
|
|
||||||
foreach ($selectboxall AS $key => $value) {
|
|
||||||
echo ' '
|
|
||||||
. '<option value="' . htmlspecialchars($key) . '"';
|
|
||||||
if ($foreign_field && $key == $foreign_field) {
|
|
||||||
echo ' selected="selected"';
|
|
||||||
$seen_key = TRUE;
|
|
||||||
}
|
}
|
||||||
echo '>' . $value . '</option>'. "\n";
|
$seen_key = FALSE;
|
||||||
} // end while
|
foreach ($selectboxall AS $key => $value) {
|
||||||
|
echo ' '
|
||||||
|
. '<option value="' . htmlspecialchars($key) . '"';
|
||||||
|
if ($foreign_field && $key == $foreign_field) {
|
||||||
|
echo ' selected="selected"';
|
||||||
|
$seen_key = TRUE;
|
||||||
|
}
|
||||||
|
echo '>' . $value . '</option>'. "\n";
|
||||||
|
} // end while
|
||||||
|
|
||||||
// if the link defined in relationtable points to a foreign field
|
// if the link defined in relationtable points to a foreign field
|
||||||
// that is not a key in the foreign table, we show the link
|
// that is not a key in the foreign table, we show the link
|
||||||
// (will not be shown with an arrow)
|
// (will not be shown with an arrow)
|
||||||
if ($foreign_field && !$seen_key) {
|
if ($foreign_field && !$seen_key) {
|
||||||
echo ' '
|
echo ' '
|
||||||
. '<option value="' . htmlspecialchars($foreign_field) . '"';
|
. '<option value="' . htmlspecialchars($foreign_field) . '"';
|
||||||
echo ' selected="selected"';
|
echo ' selected="selected"';
|
||||||
echo '>' . $foreign_field . '</option>'. "\n";
|
echo '>' . $foreign_field . '</option>'. "\n";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
<?php
|
<?php
|
||||||
|
} // end if (internal relations)
|
||||||
|
|
||||||
if ($tbl_type=='INNODB') {
|
if ($tbl_type=='INNODB') {
|
||||||
?>
|
?>
|
||||||
<td bgcolor="<?php echo ($i % 2) ? $GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo']; ?>">
|
<td bgcolor="<?php echo ($i % 2) ? $GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo']; ?>">
|
||||||
@@ -486,10 +496,12 @@ if ($col_rs && PMA_DBI_num_rows($col_rs) > 0) {
|
|||||||
</table>
|
</table>
|
||||||
<?php
|
<?php
|
||||||
if ($tbl_type=='INNODB') {
|
if ($tbl_type=='INNODB') {
|
||||||
echo $strInternalNotNecessary . '<br />';
|
if ($cfgRelation['relwork']) {
|
||||||
if (PMA_MYSQL_INT_VERSION < 40013) {
|
echo $strInternalNotNecessary . '<br />';
|
||||||
echo '** ' . sprintf($strUpgrade, 'MySQL', '4.0.13') . '<br />';
|
}
|
||||||
}
|
if (PMA_MYSQL_INT_VERSION < 40013) {
|
||||||
|
echo '** ' . sprintf($strUpgrade, 'MySQL', '4.0.13') . '<br />';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</form>
|
</form>
|
||||||
|
Reference in New Issue
Block a user