From 989ba6743b64bc251edab633ba486f9928f768d7 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 26 Jul 2011 08:24:32 -0500 Subject: [PATCH] Added support for specifying columns when paginating. --- system/db/query.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/system/db/query.php b/system/db/query.php index 3482f8c8..c4383d52 100644 --- a/system/db/query.php +++ b/system/db/query.php @@ -458,12 +458,26 @@ private function aggregate($aggregator, $column) * Get paginated query results. * * @param int $per_page + * @param array $columns * @return Paginator */ - public function paginate($per_page) + public function paginate($per_page, $columns = array('*')) { + $select = $this->select; + $total = $this->count(); + // Every query clears the SELECT clause, so we store the contents of the clause + // before executing the count query and then put the contents back in afterwards. + if ( ! is_null($select)) + { + $this->select = $select; + } + else + { + $this->select($columns); + } + $current_page = \System\Paginator::page($total, $per_page); return \System\Paginator::make($this->for_page($current_page, $per_page)->get(), $total, $per_page);