mirror of
https://github.com/vrana/adminer.git
synced 2025-08-28 08:39:53 +02:00
Separate backward keys
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@873 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
@@ -72,6 +72,14 @@ function adminer_select_links($table_status) {
|
||||
return call_adminer('select_links', '<a href="' . htmlspecialchars($SELF) . (isset($table_status["Engine"]) ? 'table=' : 'view=') . urlencode($_GET['select']) . '">' . lang('Table structure') . '</a>', $table_status);
|
||||
}
|
||||
|
||||
/** Find backward keys for table
|
||||
* @param string
|
||||
* @return array $return[$target_table][$key_name][$target_column] = $source_column;
|
||||
*/
|
||||
function adminer_backward_keys($table) {
|
||||
return call_adminer('backward_keys', array(), $table);
|
||||
}
|
||||
|
||||
/** Query printed in select before execution
|
||||
* @param string query to be executed
|
||||
* @return string
|
||||
|
@@ -285,22 +285,7 @@ if (!$columns) {
|
||||
}
|
||||
$descriptions = adminer_row_descriptions($rows, $foreign_keys);
|
||||
|
||||
//! Editor only
|
||||
$backward_keys = array();
|
||||
$result = $dbh->query("
|
||||
SELECT TABLE_NAME, CONSTRAINT_NAME, COLUMN_NAME, REFERENCED_COLUMN_NAME
|
||||
FROM information_schema.KEY_COLUMN_USAGE
|
||||
WHERE TABLE_SCHEMA = " . $dbh->quote(adminer_database()) . "
|
||||
AND REFERENCED_TABLE_SCHEMA = " . $dbh->quote(adminer_database()) . "
|
||||
AND REFERENCED_TABLE_NAME = " . $dbh->quote($_GET["select"]) . "
|
||||
ORDER BY ORDINAL_POSITION
|
||||
");
|
||||
if ($result) {
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$backward_keys[$row["TABLE_NAME"]][$row["CONSTRAINT_NAME"]][$row["COLUMN_NAME"]] = $row["REFERENCED_COLUMN_NAME"];
|
||||
}
|
||||
$result->free();
|
||||
}
|
||||
$backward_keys = adminer_backward_keys($_GET["select"]);
|
||||
$table_names = array_keys($backward_keys);
|
||||
if ($table_names) {
|
||||
$table_names = array_combine($table_names, array_map('adminer_table_name', array_map('table_status', $table_names)));
|
||||
|
Reference in New Issue
Block a user