diff --git a/adminer/plugin.php b/adminer/plugin.php index 5d60a854..9df8f32a 100644 --- a/adminer/plugin.php +++ b/adminer/plugin.php @@ -20,6 +20,7 @@ function adminer_object() { new AdminerForeignSystem, new AdminerEnumOption, new AdminerTablesFilter, + new AdminerEditForeign, ); /* It is possible to combine customization and plugins: diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index 58821b0a..4760896e 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -575,14 +575,14 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5 function _foreignKeyOptions($table, $column, $value = null) { global $connection; - if (list($table, $id, $name) = $this->_foreignColumn(column_foreign_keys($table), $column)) { - $return = &$this->_values[$table]; + if (list($target, $id, $name) = $this->_foreignColumn(column_foreign_keys($table), $column)) { + $return = &$this->_values[$target]; if (!isset($return)) { - $table_status = table_status($table); - $return = ($table_status["Rows"] > 1000 ? "" : array("" => "") + get_key_vals("SELECT $id, $name FROM " . table($table) . " ORDER BY 2")); + $table_status = table_status($target); + $return = ($table_status["Rows"] > 1000 ? "" : array("" => "") + get_key_vals("SELECT $id, $name FROM " . table($target) . " ORDER BY 2")); } if (!$return && isset($value)) { - return $connection->result("SELECT $name FROM " . table($table) . " WHERE $id = " . q($value)); + return $connection->result("SELECT $name FROM " . table($target) . " WHERE $id = " . q($value)); } return $return; } diff --git a/plugins/edit-foreign.php b/plugins/edit-foreign.php new file mode 100644 index 00000000..fa488eb3 --- /dev/null +++ b/plugins/edit-foreign.php @@ -0,0 +1,30 @@ + "") + get_vals("SELECT " . idf_escape($id) . " FROM " . table($target) . " ORDER BY 1"); + } + return "" . optionlist($options, $value) . ""; + } + } + } + +}