CodeIgniter Forums
Pagination with Join Query - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Pagination with Join Query (/showthread.php?tid=75700)



Pagination with Join Query - kick - 03-07-2020

Hi, maybe it's as simple as I am missing something in the documentation and or my search criteria. I've played around with building queries, etc and can't seem to break this problem.

Could someone point me in the direction (via documentation/code sample/function) of how to join two models/tables and still be able to use pagination in CI 4? 

Thanks for any help that you may offer.


RE: Pagination with Join Query - includebeer - 03-08-2020

I think you would need to use manual pagination: https://codeigniter4.github.io/userguide/libraries/pagination.html#manual-pagination


RE: Pagination with Join Query - kilishan - 03-09-2020

Most of the times you can intermingle calls with your model and the query builder together. So you should be able to do something like:

PHP Code:
$users $userModel->join('foo''foo.user_id = users.id')->paginate(); 



RE: Pagination with Join Query - kick - 03-09-2020

Thank you both. I have my answer.


RE: Pagination with Join Query - dudinmaster - 10-30-2021

(03-09-2020, 11:09 AM)kick Wrote: Thank you both. I have my answer.
how you can do that , may I know your solved script ?