CodeIgniter Forums
paginate/pagination ERROR - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: paginate/pagination ERROR (/showthread.php?tid=79348)



paginate/pagination ERROR - John mark bartholomon - 06-01-2021

PHP Code:
How do you use paginate() in ci4 accompanied by query()
//situation
I am trying to use the paginate() accompanied with the query() but i get error messages i tried to do one with only the model using paginate(SETUP1). I also tried to do it with only the controller(SETUP2). But both give me the same error message
CodeIgniter
\Database\MySQLi\Result::paginate()

!
SETUP1
//PART OF MY CONTROLLER
        $data["SearchData"] = $model->searchAll($sendData);
        $data["pager"] = $model->pager;

//PART OF MY MODEL(It is inside the searchAll() function)
        $query $db->query($sql)->paginate(10);
        $query->getResultArray();
        $query->sql $sql;

        return $query;
 
//error
  Call to undefined method  CodeIgniter\Database\MySQLi\Result::paginate() 


 !
SETUP2
 
//PART OF MY CONTROLLER
  $data["SearchData"] = $model->searchAll($sendData)->paginate(10);
  $data["pager"] = $model->pager;

 
//PART OF MY MODEL(It is inside the searchAll() function)
  $query $db->query($sql);
  $query->getResultArray();
  $query->sql $sql;

  return $query;

 
//(same)error
 
Call to undefined method CodeIgniter\Database\MySQLi\Result::paginate()

 
// How do I fix/make a workaround this error any  suggestions/reccomendations/help will be appreciated thank you  :) . 



RE: paginate/pagination ERROR - InsiteFX - 06-01-2021

@includebeer has a whole tutorial on this, see part 4 for pagination.
How to build a basic web application with CodeIgniter 4


RE: paginate/pagination ERROR - paliz - 06-02-2021

$data['data'] = $advertisementModel->select('*')
->where(['name'=>'x']))
->orderBy('id','desc)
->paginate(10, 'default', 1,0);

$data['pager']= $advertisementModel->pager->getDetails()