Welcome Guest, Not a member yet? Register   Sign In
Pagination with GROUP CONCAT
#1

Hi
I've been using CI4 for a month now and I'm currently facing an issue with pagination.

If I'm using it as the doc says, everything's cool. I got my pages and links. But if I want to paginate a query with a join query, a group concat and group by, my results are bad.

PHP Code:
$this->foo = new FooModel();
$data['foo'] = $this->foo
                
->select('foo.*')
                ->
select('GROUP_CONCAT(BAR_FOO_ID) as BAR_FOO_ID')
                ->
join('bar_has_foo''BAR_FOO_ID = FOO_ID''LEFT')
                ->
groupBy('FOO_ID')
                ->
paginate(20);
        
$data['pager'] = $this->rtiers->pager

If I dump $data['pager'], it says I have only one page with 20 results. But if I go to my view that have $data as a parameter, I can navigate to myurl?page=X without any problem.

Do you guys have any idea on how to work around this problem?
Thanks
Reply
#2

(This post was last modified: 06-19-2020, 03:08 PM by jhohh.)

This may have the same "order by" problem mentioned in system / Database / BaseBuilder.php in "function countAllResults".
you could add the same functionality that "order by" has
Reply




Theme © iAndrew 2016 - Forum software by © MyBB