Change the paginate method |
Hi! Since the manual numbering of pages in the method $ pager->makeLinks ($page, $perPage, $total) is $total,
I propose to change the paginate method in the System/Model.php: PHP Code: public function paginate(int $perPage = 20, string $group = 'default', int $page = 0,bool return_with_total = false) Code: 2019-05-25T08:55:27.306774Z 33 Query SELECT COUNT(*) AS `numrows`
Paginate acts as findAll with auto applied limit + offset and prepared Pager..
I think that logically countAllResults(false) should preserve the count once it's done and just to return it instead making multiple selects further.. https://github.com/codeigniter4/CodeIgni....php#L1566 Running that query multiple times in case $sql and $this->binds are the same is pointless specially if $reset is set to false.. Best VPS Hosting : Digital Ocean
You know better! But now the following code accesses the database 3 times and this is not correct:
PHP Code: $segment = 3; The first call to the COUNT database: $total = $model->countAllResults(false); The second two calls to the COUNT and * DB: $model->paginate($perPage,$template,$page) |
Welcome Guest, Not a member yet? Register Sign In |