• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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 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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.