Skip to content

Commit 100d7a8

Browse files
committed
Fix less page count case
1 parent b9f550c commit 100d7a8

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ $query = $this->db->where('type', 'C');
7474
$countQuery = clone $query;
7575

7676
// Get total count from cloned query
77+
// Or you could use count_all_results('', false) to keep query instead of using `clone`
7778
$count = $countQuery->count_all_results();
7879

7980
// Initialize a Data Pagination with previous count number
@@ -356,7 +357,8 @@ $query = $this->Post_model->find()
356357
$countQuery = clone $query;
357358

358359
// Get total count from cloned query
359-
$count = $countQuery->count_all_results();
360+
// Or you could use count(false) to keep query instead of using `clone`
361+
$count = $countQuery->count();
360362

361363
// Initialize a Data Pagination with previous count number
362364
$pagination = new \yidas\data\Pagination([

src/widgets/Pagination.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,19 @@ public function run()
195195
}
196196
}
197197
}
198+
elseif ($this->pagination->pageCount < 1) {
199+
200+
// Empty
201+
$this->_buttonStack[] = 1;
202+
}
203+
else {
204+
205+
// Under count number
206+
for ($i=1; $i <= $this->pagination->pageCount; $i++) {
207+
208+
$this->_buttonStack[] = $i;
209+
}
210+
}
198211

199212
// Link Attributes to html string
200213
$linkAttributes = '';

0 commit comments

Comments
 (0)