CodeIgniter Forums
[SOLVED] Pagination - 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: [SOLVED] Pagination (/showthread.php?tid=73692)



[SOLVED] Pagination - gabrielcantarin - 05-22-2019

Using this method the pagination is working fine! But how can I filter the data? For example I'm logged with user id: 1 and I want to see only companies that belongs to this user.

Using the instance like this I'll always get all the rows of this table =/

public function list(){
        $companyModel = new CompanyModel();
        
        $data = [
            'obj' => $companyModel->paginate(20, 'group1'),
            'pager' => $companyModel->pager
        ];
        
        echo view('Template/header');
        echo view('Company/listar', $data);
        echo view('Template/footer');
 }


RE: Pagination - kilishan - 05-22-2019

Code:
$companyModel
    ->where('user_id', 1)
    ->paginate(20, 'group1'),



RE: Pagination - gabrielcantarin - 05-23-2019

Thank you a lot [b]kilishan[/b]!!!!

This works!
Code:
$companyModel
   ->where('user_id', 1)
   ->paginate(20, 'group1'),

This DONT work
Code:
$companyModel
   ->paginate(20, 'group1'),
   ->where('user_id', 1)

Pay attention in the order when creating a pagination guys!