I am working on codeigniter project. I am showing news table with join left news category and paginate. When I tried the below code I get an error Call to undefined method CodeIgniter\Database\MySQLi\Builder::paginate()
. How to show news data with join and pagination?
$db = \Config\Database::connect();
$news_tbl = $db->table('tbl_news')->join('tbl_category', 'tbl_news.category_id = tbl_category.category_id');
$data['news_fetched'] = $news_tbl->paginate(10);
$data['pager'] = $news_fetched->pager;
$data['links'] = $data['pager']->links();
pagination()
. codeigniter.com/user_guide/libraries/pagination.html Do you need to load the service whereever it is that you are calling this? (I assume your model, but I have seen questions with querybuilder calls inappropriately coming from controllers.)