Change the paginate method - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Feature Requests (https://forum.codeigniter.com/forumdisplay.php?fid=29) +--- Thread: Change the paginate method (/showthread.php?tid=73709) |
Change the paginate method - videoproc - 05-25-2019 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` RE: Change the paginate method - sv3tli0 - 05-29-2019 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/CodeIgniter4/blob/develop/system/Database/BaseBuilder.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.. RE: Change the paginate method - videoproc - 05-30-2019 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) |