MySQL: Fix getting foreign keys
This commit is contained in:
parent
b7b4157bcb
commit
d5bf51b2a7
|
@ -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),
|
||||||
|
|
Loading…
Reference in a new issue