Welcome Guest, Not a member yet? Register   Sign In
paginate/pagination ERROR
#1

(This post was last modified: 06-01-2021, 02:07 AM by John mark bartholomon.)

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  :) . 
Reply
#2

@includebeer has a whole tutorial on this, see part 4 for pagination.
How to build a basic web application with CodeIgniter 4
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

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

$data['pager']= $advertisementModel->pager->getDetails()
Enlightenment  Is  Freedom
Reply




Theme © iAndrew 2016 - Forum software by © MyBB