CodeIgniter Forums
Why CI4 docs does not touch pagination class for Query Builder - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Why CI4 docs does not touch pagination class for Query Builder (/showthread.php?tid=75979)



Why CI4 docs does not touch pagination class for Query Builder - seunex - 04-03-2020

I have work so deep loving ci4 with query builder but i find it hard to make pagination. 

While checked to docs it only explain how to use it with the Model no query builder explanation.

I try to use the Manual pagination and set offset in my query but not working properly instead of return the next paging it only return one result for the next paging and join it to the ckurent paging . am defiantly stuck here.

controller:
PHP Code:
$blog = new BlogModel();

                //* Retrieve blogs
                $total $blog->getActiveBlogTotal();

                $segment route_to('adminBlogPost''active');
                if($this->request->uri->getTotalSegments() == 4)
                {
                    $page $this->request->uri->getSegment(4);
                }
                else
                {
                    $page 1;
                }
                $perPage 5;
                $pages $pager->makeLinks($page$perPage$total'admin_pag'5);

                $blogs $blog->getActiveBlogsInAdmin($page);
                return $this->smarty->view('blog/active.tpl'compact(
                    'blogs',
                    'pages'
                )); 


My model:
PHP Code:
//* Get blog in admin
    public function getActiveBlogsInAdmin($page)
    {
        
        $table 
$this->db->table('zd_blogs');
        $table->select('*');
        $table->join('zd_main_cats''zd_main_cats.main_cat_id = zd_blogs.blog_main_cat''left');
        $table->join('zd_users''zd_users.user_id = zd_blogs.blog_user''left');
        $table->where('zd_blogs.blog_status'1);
        $table->where('zd_blogs.blog_deleted'0);
        $table->orderBy('zd_blogs.blog_id''DESC');
        $table->limit(5$page);
        $query $table->get();
        if($table->countAllResults() > 0)
        {
            return $query->getResult();
        }
        else
        {
            return FALSE;
        }
    


I will really appreciate if some one can be kind enough to give me a clear through