Check MySQL version
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1154 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
parent
8625e91e73
commit
b60ed1ba95
|
@ -50,17 +50,16 @@ class Adminer {
|
||||||
function backwardKeys($table, $tableName) {
|
function backwardKeys($table, $tableName) {
|
||||||
global $connection;
|
global $connection;
|
||||||
$return = array();
|
$return = array();
|
||||||
|
if ($connection->server_info >= 5) { //! requires MySQL 5
|
||||||
$result = $connection->query("SELECT TABLE_NAME, CONSTRAINT_NAME, COLUMN_NAME, REFERENCED_COLUMN_NAME
|
$result = $connection->query("SELECT TABLE_NAME, CONSTRAINT_NAME, COLUMN_NAME, REFERENCED_COLUMN_NAME
|
||||||
FROM information_schema.KEY_COLUMN_USAGE
|
FROM information_schema.KEY_COLUMN_USAGE
|
||||||
WHERE TABLE_SCHEMA = " . $connection->quote($this->database()) . "
|
WHERE TABLE_SCHEMA = " . $connection->quote($this->database()) . "
|
||||||
AND REFERENCED_TABLE_SCHEMA = " . $connection->quote($this->database()) . "
|
AND REFERENCED_TABLE_SCHEMA = " . $connection->quote($this->database()) . "
|
||||||
AND REFERENCED_TABLE_NAME = " . $connection->quote($table) . "
|
AND REFERENCED_TABLE_NAME = " . $connection->quote($table) . "
|
||||||
ORDER BY ORDINAL_POSITION"); //! requires MySQL 5
|
ORDER BY ORDINAL_POSITION");
|
||||||
if ($result) {
|
|
||||||
while ($row = $result->fetch_assoc()) {
|
while ($row = $result->fetch_assoc()) {
|
||||||
$return[$row["TABLE_NAME"]]["keys"][$row["CONSTRAINT_NAME"]][$row["COLUMN_NAME"]] = $row["REFERENCED_COLUMN_NAME"];
|
$return[$row["TABLE_NAME"]]["keys"][$row["CONSTRAINT_NAME"]][$row["COLUMN_NAME"]] = $row["REFERENCED_COLUMN_NAME"];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
foreach ($return as $key => $val) {
|
foreach ($return as $key => $val) {
|
||||||
$name = $this->tableName(table_status($key));
|
$name = $this->tableName(table_status($key));
|
||||||
if (strlen($name)) {
|
if (strlen($name)) {
|
||||||
|
@ -71,6 +70,7 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5
|
||||||
unset($return[$key]);
|
unset($return[$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue