double0201 2016-02-07 04:25
浏览 58

Codeigniter致命错误:调用未定义的方法Pagination :: initialize()

I am trying to user the Codeigniter pagination and I receive the following error "Fatal error: Call to undefined method Pagination::initialize()".

I found a few post with the same issue but they all stated the solution is to auto load the Pagination class which I am already doing. The only issue I can think of is that my class uses custom controller "MY_Controller" which extends the CI controller. Below is my code, please help. Thanks in advance.

MY_Controller.php

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Controller extends CI_Controller {

public function __construct()
{
    parent::__construct();

    $this->init();
}

}

Main Controller

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Main extends MY_Controller {

function index()
{
    $this->display();   
}

function display()
{
//pagination settings
$config['base_url']    = base_url();
$config['total_rows']  = 200;
$config['per_page']    = 50;

$this->pagination->initialize($config);
}
}
  • 写回答

1条回答 默认 最新

  • dongzhuner6981 2016-02-07 04:48
    关注

    If you made a custom controller and extend it with core My_Controller than load pagination library inside the display() function:

    $this->load->library('pagination');
    
    评论

报告相同问题?

悬赏问题

  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答