diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php index 8030b8ec..03a50d13 100644 --- a/adminer/include/functions.inc.php +++ b/adminer/include/functions.inc.php @@ -905,6 +905,7 @@ function is_url($string) { function kill_timeout() { global $adminer, $token; $kill = mt_rand(); + if (support("kill")) { ?> clearTimeout(timeout);\n"; - ob_flush(); - flush(); - if ($connection->errno == 2006) { // 2006 - CR_SERVER_GONE_ERROR - $connection2 = connect(); - if (is_object($connection2)) { - $connection = $connection2; + if (support("kill")) { + echo "\n"; + ob_flush(); + flush(); + if ($connection->errno == 2006) { // 2006 - CR_SERVER_GONE_ERROR + $connection2 = connect(); + if (is_object($connection2)) { + $connection = $connection2; + } } } } diff --git a/adminer/select.inc.php b/adminer/select.inc.php index 23c2329e..5f176deb 100644 --- a/adminer/select.inc.php +++ b/adminer/select.inc.php @@ -393,25 +393,28 @@ if (!$columns) { $found_rows = found_rows($table_status, $where); if ($found_rows < max(1e4, 2 * ($page + 1) * $limit)) { // slow with big tables - ob_flush(); - flush(); - $found_rows = $connection->result("SELECT COUNT(*) FROM " . table($TABLE) . ($where ? " WHERE " . implode(" AND ", $where) : "")); + $kill = kill_timeout(); + $found_rows = @$connection->result("/* Adminer $kill */ SELECT COUNT(*) FROM " . table($TABLE) . ($where ? " WHERE " . implode(" AND ", $where) : "")); // @ - may be kill + cancel_kill_timeout(); } else { $exact_count = false; } } echo "

"; - if (+$limit && $found_rows > $limit) { + if (+$limit && ($found_rows === false || $found_rows > $limit)) { // display first, previous 4, next 4 and last page - $max_page = floor(($found_rows - 1) / $limit); + $max_page = ($found_rows === false + ? $page + (count($rows) >= $limit ? 2 : 1) + : floor(($found_rows - 1) / $limit) + ); echo '" . lang('Page') . ":"; echo pagination(0, $page) . ($page > 5 ? " ..." : ""); for ($i = max(1, $page - 4); $i < min($max_page, $page + 5); $i++) { echo pagination($i, $page); } - echo ($page + 5 < $max_page ? " ..." : "") . ($exact_count ? pagination($max_page, $page) : ' ' . lang('last') . ""); + echo ($page + 5 < $max_page ? " ..." : "") . ($exact_count && $found_rows !== false ? pagination($max_page, $page) : ' ' . lang('last') . ""); } - echo " (" . ($exact_count ? "" : "~ ") . lang('%d row(s)', $found_rows) . ") " . checkbox("all", 1, 0, lang('whole result')) . "\n"; + echo ($found_rows !== false ? " (" . ($exact_count ? "" : "~ ") . lang('%d row(s)', $found_rows) . ")" : "") . " " . checkbox("all", 1, 0, lang('whole result')) . "\n"; if ($adminer->selectCommandPrint()) { ?> diff --git a/changes.txt b/changes.txt index 34761b55..bdcff9b4 100644 --- a/changes.txt +++ b/changes.txt @@ -1,6 +1,6 @@ Adminer 3.5.2-dev: Edit strings with \n in textarea -Time out long running database list +Time out long running database list and select count Use VALUES() in INSERT+UPDATE export Style logout button as link