From effa00f2097143fdb07fcd026f592c51d7879a50 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Tue, 15 Oct 2013 15:36:13 -0400 Subject: [PATCH] Bug #4135 When searching, error "No database selected" --- libraries/sql.lib.php | 4 +++- sql.php | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/sql.lib.php b/libraries/sql.lib.php index c82531c5ec..d5694f3e8f 100644 --- a/libraries/sql.lib.php +++ b/libraries/sql.lib.php @@ -1319,7 +1319,8 @@ function PMA_hasCurrentDbChanged($db) $reload = 0; if (strlen($db)) { $current_db = $GLOBALS['dbi']->fetchValue('SELECT DATABASE()'); - if ($db !== $current_db) { + // $current_db is false, except when a USE statement was sent + if ($current_db != false && $db !== $current_db) { $reload = 1; } } @@ -2286,6 +2287,7 @@ function PMA_executeQueryAndSendQueryResponse($analyzed_sql_results, } $GLOBALS['reload'] = PMA_hasCurrentDbChanged($db); + $GLOBALS['dbi']->selectDb($db); // Execute the query list($result, $num_rows, $unlim_num_rows, $profiling_results, diff --git a/sql.php b/sql.php index a4ee7beb59..5006dc8b65 100644 --- a/sql.php +++ b/sql.php @@ -173,7 +173,6 @@ if ($goto == 'sql.php') { ); } // end if -$GLOBALS['dbi']->selectDb($db); PMA_executeQueryAndSendQueryResponse( $analyzed_sql_results, $is_gotofile,