diff options
author | Steven Wittens <steven@10.no-reply.drupal.org> | 2004-12-06 11:57:04 +0000 |
---|---|---|
committer | Steven Wittens <steven@10.no-reply.drupal.org> | 2004-12-06 11:57:04 +0000 |
commit | 01d216018f3c8789917ee670b2e27f8b08436426 (patch) | |
tree | 34e5e2a43409daa009cb6dc72f17351970df9b7d /includes/pager.inc | |
parent | c9cbf291765a509c7ef33c7964f0d7b431cf3b2c (diff) | |
download | brdo-01d216018f3c8789917ee670b2e27f8b08436426.tar.gz brdo-01d216018f3c8789917ee670b2e27f8b08436426.tar.bz2 |
Pager_query's count query was broken if no query arguments were given.
Diffstat (limited to 'includes/pager.inc')
-rw-r--r-- | includes/pager.inc | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/includes/pager.inc b/includes/pager.inc index bf850f5b7..fb4452e03 100644 --- a/includes/pager.inc +++ b/includes/pager.inc @@ -60,20 +60,21 @@ function pager_query($query, $limit = 10, $element = 0, $count_query = NULL) { $args = $args[0]; } - // Count the total number of records in this query. + // Construct a count query if none was given. if (!isset($count_query)) { $count_query = preg_replace(array('/SELECT.*?FROM/As', '/ORDER BY .*/'), array('SELECT COUNT(*) FROM', ''), $query); } - $pager_total[$element] = db_result(db_query($count_query, $args)); // Convert comma-separated $from to an array, used by other functions. $pager_from_array = explode(',', $from); - if (count($args)) { - return db_query_range($query, $args, (int)$pager_from_array[$element], (int)$limit); - } - else { - return db_query_range($query, (int)$pager_from_array[$element], (int)$limit); + if (count($args)) { + $pager_total[$element] = db_result(db_query($count_query, $args)); + return db_query_range($query, $args, (int)$pager_from_array[$element], (int)$limit); + } + else { + $pager_total[$element] = db_result(db_query($count_query)); + return db_query_range($query, (int)$pager_from_array[$element], (int)$limit); } } |