From 3a73815ba47cca4a36ccab9a9b304c10d5c044b3 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Mon, 14 Apr 2025 09:21:51 +0200 Subject: [PATCH] Do not attempt allFields without DB (fix #1033) --- adminer/include/driver.inc.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/adminer/include/driver.inc.php b/adminer/include/driver.inc.php index a7e05443..8cd1b208 100644 --- a/adminer/include/driver.inc.php +++ b/adminer/include/driver.inc.php @@ -268,14 +268,16 @@ AND CHECK_CLAUSE NOT LIKE '% IS NOT NULL'", $this->conn); // ignore default IS N */ function allFields(): array { $return = array(); - foreach ( - get_rows("SELECT TABLE_NAME AS tab, COLUMN_NAME AS field, IS_NULLABLE AS nullable, DATA_TYPE AS type, CHARACTER_MAXIMUM_LENGTH AS length" . (JUSH == 'sql' ? ", COLUMN_KEY = 'PRI' AS `primary`" : "") . " + if (DB != "") { + foreach ( + get_rows("SELECT TABLE_NAME AS tab, COLUMN_NAME AS field, IS_NULLABLE AS nullable, DATA_TYPE AS type, CHARACTER_MAXIMUM_LENGTH AS length" . (JUSH == 'sql' ? ", COLUMN_KEY = 'PRI' AS `primary`" : "") . " FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = " . q($_GET["ns"] != "" ? $_GET["ns"] : DB) . " ORDER BY TABLE_NAME, ORDINAL_POSITION", $this->conn) as $row - ) { - $row["null"] = ($row["nullable"] == "YES"); - $return[$row["tab"]][] = $row; + ) { + $row["null"] = ($row["nullable"] == "YES"); + $return[$row["tab"]][] = $row; + } } return $return; }