mirror of
https://github.com/vrana/adminer.git
synced 2025-08-20 21:31:44 +02:00
MySQL: Fix getting foreign keys
This commit is contained in:
@@ -583,8 +583,8 @@ if (!defined("DRIVER")) {
|
|||||||
*/
|
*/
|
||||||
function foreign_keys($table) {
|
function foreign_keys($table) {
|
||||||
$return = array();
|
$return = array();
|
||||||
foreach (get_rows("SELECT * FROM information_schema.REFERENTIAL_CONSTRAINTS WHERE CONSTRAINT_SCHEMA = " . q(DB) . " AND TABLE_NAME = " . q($table)) as $row) {
|
foreach (get_rows("SELECT * FROM information_schema.REFERENTIAL_CONSTRAINTS WHERE CONSTRAINT_SCHEMA = DATABASE() AND TABLE_NAME = " . q($table)) as $row) {
|
||||||
$columns = get_key_vals("SELECT COLUMN_NAME, REFERENCED_COLUMN_NAME FROM information_schema.KEY_COLUMN_USAGE WHERE CONSTRAINT_SCHEMA = " . q(DB) . " AND CONSTRAINT_NAME = " . q($row["CONSTRAINT_NAME"]) . " ORDER BY ORDINAL_POSITION");
|
$columns = get_key_vals("SELECT COLUMN_NAME, REFERENCED_COLUMN_NAME FROM information_schema.KEY_COLUMN_USAGE WHERE CONSTRAINT_SCHEMA = DATABASE() AND CONSTRAINT_NAME = " . q($row["CONSTRAINT_NAME"]) . " ORDER BY ORDINAL_POSITION");
|
||||||
$db = $row["UNIQUE_CONSTRAINT_SCHEMA"];
|
$db = $row["UNIQUE_CONSTRAINT_SCHEMA"];
|
||||||
$return[$row["CONSTRAINT_NAME"]] = array(
|
$return[$row["CONSTRAINT_NAME"]] = array(
|
||||||
"db" => ($db == DB ? "" : $db),
|
"db" => ($db == DB ? "" : $db),
|
||||||
|
Reference in New Issue
Block a user