CodeIgniter Forums
Pagination with GROUP CONCAT - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forum-30.html)
+--- Thread: Pagination with GROUP CONCAT (/thread-76136.html)



Pagination with GROUP CONCAT - ViLar - 04-16-2020

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


RE: Pagination with GROUP CONCAT - jhohh - 06-16-2020

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