CI 4 pagination problem |
How do I paginate only selected items from a table.
Controller: PHP Code: <?php Model: PHP Code: <?php View PHP Code: <!doctype html> Zawsze dostaję błąd: Illegal string offset 'id' w widoku.
I also had problems at first and I ended up doing this.
The code should give you an idea of how to do it, you will notice I am returning $this so that we can use method chaining. Don't worry about the group stuff it's because I have custom bootstrap pager templates. PHP Code: // CONTROLLER This works like a charm for me. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Thank you, it also worked for me. I'm just wondering how to do it by writing SQL queries?
Just run the queries and than return $this
Which allows you to chain on the paginate method. So: PHP Code: $data['test'] = $model->yourQuery->paginate(10); Don't tell your model methods to return any object or array the paginate uses the find method to return everything. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
With Query, you can
1. Get current page: $curPage = $pager->getCurrentPage(); 2. In your query, use LIMIT: LIMIT $curPage * $perPage, $perPage Learning CI4 from my works, from errors and how to fix bugs in the community Love CI & Thanks CI Teams |
Welcome Guest, Not a member yet? Register Sign In |