• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pagination don't work

#1
Hi all!
I'm trying to configure pagination for my project, I do everything according to the documentation, but I get an error. With version 3, there were no such problems ((

PHP Code:
lass User extends Controller{
    
    
public $model;
    public $locale;

    function __construct()
    {
        $this->locale  =  service('request')->getLocale();
        $this->model = new UserModel();
    

    /*
     * Listing of users
     */
    function index()
    {

        $data = [
            'users'=>$this->model->get_all_users()->paginate(10),
            'pager'=>$this->model->get_all_users()->pager,
            'locale' => $this->locale
        
];

        echo view('admin/header',$data);
        echo view('admin/user/index',$data);
        echo view('admin/footer');
    

Model:
PHP Code:
class UserModel extends Model
{
    protected $db;
    protected $builder;

    function __construct()
    {
        $this->db = \Config\Database::connect();
        $this->builder $this->db->table('users');
    }
  /*
     * Get all users
     */
    function get_all_users()
    {

//        $this->builder->select('id_user, name_user');
        $this->builder->orderBy('id_user''asc');

        return $this->builder->get()->getResultArray();
    
Error:

Quote:Error
Call to a member function paginate() on array search →
Reply

#2
as it turned out, in the file \system\Model.php, line 442

$ this-> tempReturnType = $ this-> returnType; costs AFTER $ row = $ row-> getResult ($ this-> tempReturnType); I moved it before this expression and it worked.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.