Welcome Guest, Not a member yet? Register   Sign In
Codeigniter 4 Pagination With Join and Where sql

(This post was last modified: 06-24-2022, 12:37 AM by demyr.)

(06-23-2022, 10:26 PM)kenjis Wrote:
(06-23-2022, 09:55 PM)demyr Wrote: But the thing I face here is the $total variable. It is not usable. Because imagine the total is 6 and I have 3 results per page for 10 results. Then after the second or third pagination it keeps showing the same, the last, item for the rest of the paginations.

Sorry, I don't get what you say.

$page is the current page number, starting at 1.
$perPage is the number of the records found you show on one page.
$total is the number of total records found.

And you need to modify get_all_offers_pending() so that returns data set with limit and offset.
The limit is $perPage. The offset can be calculated from $page.

I believe limit and offset cannot solve the problem since offset creates a starting point until it reaches limit, am I right? says: "return only 10 records, start on record 16 (OFFSET 15)" on w3school

You have defined $total as 20, but how can we know it beforehand? With a regular data fetch from $perPage or $total doesn't work.

It only works when I call my datas within controller as :

PHP Code:
$model = new \App\Models\AdminModels\OffersModel();
$data['offers_pending'] = $model->where('offer_status''pending')->paginate(2); 

However, how can I join here with the same column names like fk ?

So, whatever I try, the result is not healthy.

P.S. edit for the uncceserray spaces in the post

Messages In This Thread
RE: Codeigniter 4 Pagination With Join and Where sql - by demyr - 06-24-2022, 12:28 AM

Theme © iAndrew 2016 - Forum software by © MyBB