简体   繁体   中英

Undefined property: Purchase::$purchase_model codeigniter

This is the most strange error I have seen in my life, because yesterday it was working and I wake up today and it's not working this is the error:

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Purchase::$purchase_model

Filename: controllers/purchase.php

Line Number: 67

Here is the controller code class Purchase extends CI_Controller {

function __construct()
{
    parent::__construct();
    $this->load->model('purchase_model', 'user_model');
    $this->load->helper(array('form', 'url'));
    $this->load->library(array('form_validation', 'upload'));
}   

 function steptwo()
{   
    if($this->input->post('templateid') == NULL){
        redirect('templates');
        }
    $data =$_POST;
    if($this->session->userdata('userName')){
    $data['name']=$this->session->userdata('userName'); 
    }else{ $data['name'] = NULL;}
    $data['paymentplans'] = $this->purchase_model->GetPplan(array('id_template_type' => $_POST['idtype']));
    $this->load->view('step-two', $data);
}

An here is my model code:

   class Purchase_Model extends CI_Model
    {
        function GetPplan($options = array())
{
    // Qualification
    if(isset($options['id_template_type']))
        $this->db->where('id_template_type', $options['id_template_type']);

    // limit / offset
    if(isset($options['limit']) && isset($options['offset']))
        $this->db->limit($options['limit'], $options['offset']);
    else if(isset($options['limit']))
        $this->db->limit($options['limit']);

    // sort
    if(isset($options['sortBy']) && isset($options['sortDirection']))
        $this->db->order_by($options['sortBy'], $options['sortDirection']);


    $query = $this->db->get("template_payment_plan");

    if(isset($options['count'])) return $query->num_rows();

    if(isset($options['template_payment_planid']) || isset($options['detail']))
        return $query->row(0);

    return $query->result();
}    
 }

I already have done this $autoload['libraries'] = array('database', 'session'); so I don't think this was the problem.

If anyone know what can the error be I'll be really grateful

$this->load->model('purchase_model', 'user_model');

Here you load purchase_model that you call user_model, if you want load two models, make this :

$this->load->model('purchase_model');
$this->load->model('user_model');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM