Skip to content
Browse files

FOUND_ROWS works with last SELECT

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@844 7c3ca157-0c34-0410-bff1-cbf682f78f5c
  • Loading branch information...
1 parent 56948c9 commit 4cdc4598c7297018ff13f2d1500b904bfd4fc72d jakubvrana committed Jul 16, 2009
Showing with 11 additions and 5 deletions.
  1. +11 −5 adminer/select.inc.php
View
16 adminer/select.inc.php
@@ -270,6 +270,11 @@
$rows[] = $row;
}
$result->free();
+ // use count($rows) without LIMIT, COUNT(*) without grouping, FOUND_ROWS otherwise (slowest)
+ $found_rows = (intval($limit) && count($group) < count($select)
+ ? $dbh->result($dbh->query(" SELECT FOUND_ROWS()")) // space to allow mysql.trace_mode
+ : count($rows)
+ );
$foreign_keys = array();
foreach (foreign_keys($_GET["select"]) as $foreign_key) {
@@ -357,12 +362,13 @@
}
echo "</table>\n";
+ if (intval($limit) && count($group) >= count($select)) {
+ // slow with big tables
+ ob_flush();
+ flush();
+ $found_rows = $dbh->result($dbh->query("SELECT COUNT(*) FROM " . idf_escape($_GET["select"]) . ($where ? " WHERE " . implode(" AND ", $where) : "")));
+ }
echo "<p>";
- // use count($rows) without LIMIT, COUNT(*) without grouping, FOUND_ROWS otherwise (slowest)
- $found_rows = (intval($limit) ? $dbh->result($dbh->query(count($group) < count($select)
- ? " SELECT FOUND_ROWS()" // space to allow mysql.trace_mode
- : "SELECT COUNT(*) FROM " . idf_escape($_GET["select"]) . ($where ? " WHERE " . implode(" AND ", $where) : "")
- )) : count($rows));
if (intval($limit) && $found_rows > $limit) {
// display first, previous 3, next 3 and last page
$max_page = floor(($found_rows - 1) / $limit);

0 comments on commit 4cdc459

Please sign in to comment.
Something went wrong with that request. Please try again.