From 051b4e9a5b5ce940e30e70222c5648a7dc2c7de8 Mon Sep 17 00:00:00 2001 From: jakubvrana Date: Thu, 30 Jul 2009 14:12:18 +0000 Subject: [PATCH] First available database or current user without list git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@949 7c3ca157-0c34-0410-bff1-cbf682f78f5c --- editor/include/adminer.inc.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index ab031c02..e6e41453 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -10,8 +10,12 @@ class Adminer { } function database() { + global $dbh; $dbs = get_databases(false); - return (count($dbs) == 1 ? $dbs[0] : (count($dbs) == 2 && information_schema($dbs[0]) ? $dbs[1] : 'test')); + return (!$dbs + ? $dbh->result($dbh->query("SELECT SUBSTRING_INDEX(CURRENT_USER, '@', 1)")) // username without the database list + : $dbs[(information_schema($dbs[0]) ? 1 : 0)] // first available database + ); } function loginForm($username) {