diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index 6d1cc457..ebe8969d 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -88,12 +88,21 @@ class Adminer { /** Find backward keys for table * @param string - * @return array $return[$target_table][$key_name][$target_column] = $source_column; + * @param string + * @return array $return[$target_table]["keys"][$key_name][$target_column] = $source_column; $return[$target_table]["name"] = $this->tableName($target_table); */ - function backwardKeys($table) { + function backwardKeys($table, $tableName) { return array(); } + /** Print backward keys for row + * @param array result of $this->backwardKeys() + * @param array + * @return null + */ + function backwardKeysPrint($backwardKeys, $row) { + } + /** Query printed in select before execution * @param string query to be executed * @return string @@ -461,7 +470,7 @@ class Adminer {
printTables($missing); + $this->tablesPrint($missing); } } @@ -469,7 +478,7 @@ class Adminer { * @param string can be "db" if there is no database selected * @return null */ - function printTables($missing) { + function tablesPrint($missing) { global $connection; if ($missing != "db" && strlen(DB) && $connection->select_db(DB)) { $result = $connection->query("SHOW TABLES"); diff --git a/adminer/select.inc.php b/adminer/select.inc.php index a698e16d..ad77fdb6 100644 --- a/adminer/select.inc.php +++ b/adminer/select.inc.php @@ -174,16 +174,7 @@ if (!$columns) { : count($rows) ); - $backward_keys = $adminer->backwardKeys($TABLE); - $table_names = array(); - if ($backward_keys) { - foreach ($backward_keys as $key => $val) { - $val = $adminer->tableName(table_status($key)); - if (strlen($val)) { - $table_names[$key] = (preg_match('(^' . preg_quote($table_name) . '(:|\\s*-)?\\s+(.+))', $val, $match) ? $match[2] : $val); - } - } - } + $backward_keys = $adminer->backwardKeys($TABLE, $table_name); echo ""; @@ -201,7 +192,7 @@ if (!$columns) { } next($select); } - echo ($table_names ? " | " . lang('Relations') : "") . " | " . lang('Relations') : "") . "\n"; foreach ($adminer->rowDescriptions($rows, $foreign_keys) as $n => $row) { $unique_idf = implode('&', unique_idf($rows[$n], $indexes)); echo " |
---|---|---|
" . (count($select) != count($group) || information_schema(DB) ? '' : " " . lang('edit') . ""); @@ -245,19 +236,7 @@ if (!$columns) { echo " | $val"; } } - if ($table_names) { - echo " | "; - foreach ($table_names as $table => $name) { - foreach ($backward_keys[$table] as $cols) { - $link = ME . 'select=' . urlencode($table); - $i = 0; - foreach ($cols as $column => $val) { - $link .= where_link($i++, $column, $rows[$n][$val]); - } - echo " $name"; - } - } - } + $adminer->backwardKeysPrint($backward_keys, $rows[$n]); echo "\n"; } echo " |