douxiongye5779 2014-08-14 02:56
浏览 73
已采纳

致命错误:调用成员函数initialize()

I've controller like this

function view()
    {
        if($this->tank_auth->get_user_role_id() == 1){
            $users = null;
        }else{
            $users = $this->_get_users_id();
        }
        //count total rows of transaction list
        $this->db->where('user_id',$users);
        $this->db->from('book_packages');
        $config['base_url'] = base_url().'index.php/transaction/view';
        $config['total_rows'] = $this->db->count_all_results();
        $config['per_page'] = 10;
        $config['uri_segment'] = 3;
        $config['num_links'] = 1;

        /* this is config tag */

        $this->pagination->initialize($config);
        $data['total_rows'] = $config['total_rows'] ;
        $data['title'] = 'List transaction';
        $data['text'] = $this->transaction_model->view_transaction($config['per_page'],$this->uri->segment(3),$users);
        $data['pagecontent'] = "admin/view_transaction";
        $this->load->vars($data);
        $this->load->view('template');

    }

I echo this in the view $this->pagination->create_links(); when I load the controller I got error like this

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Transaction::$pagination

Filename: controllers/transaction.php

Line Number: 804

Fatal error: Call to a member function initialize() on a non-object in my directory

I don't know why, I already load the library pagination, helper url, the name of class with capital. and it's happen when I upload my code to hosting, but I not get any error when I load it in localhost.

any help are really appreciated. Thank you very much.

  • 写回答

3条回答 默认 最新

  • dphs48626 2014-08-14 04:17
    关注
    function view()
        {
            if($this->tank_auth->get_user_role_id() == 1){
                $users = null;
            }else{
                $users = $this->_get_users_id();
            }
            //count total rows of transaction list
            $this->db->where('user_id',$users);
            $this->db->from('book_packages');
            $config['base_url'] = base_url().'index.php/transaction/view';
            $config['total_rows'] = $this->db->count_all_results();
            $config['per_page'] = 10;
            $config['uri_segment'] = 3;
            $config['num_links'] = 1;
    
            /* this is config tag */
    
    
            /*THIS IS MISSING*/
            $this->load->library('pagination');
    
    
    
    
            $this->pagination->initialize($config);
            $data['total_rows'] = $config['total_rows'] ;
            $data['title'] = 'List transaction';
            $data['text'] = $this->transaction_model->view_transaction($config['per_page'],$this->uri->segment(3),$users);
            $data['pagecontent'] = "admin/view_transaction";
            $this->load->vars($data);
            $this->load->view('template');
    
        }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题
  • ¥20 云服务Linux系统TCP-MSS值修改?
  • ¥20 关于#单片机#的问题:项目:使用模拟iic与ov2640通讯环境:F407问题:读取的ID号总是0xff,自己调了调发现在读从机数据时,SDA线上并未有信号变化(语言-c语言)
  • ¥20 怎么在stm32门禁成品上增加查询记录功能
  • ¥15 Source insight编写代码后使用CCS5.2版本import之后,代码跳到注释行里面
  • ¥50 NT4.0系统 STOP:0X0000007B
  • ¥15 想问一下stata17中这段代码哪里有问题呀
  • ¥15 flink cdc无法实时同步mysql数据
  • ¥100 有人会搭建GPT-J-6B框架吗?有偿