0

这是我一生中见过的最奇怪的错误,因为昨天它还在工作,而我今天醒来却没有工作,这是错误:

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Purchase::$purchase_model

Filename: controllers/purchase.php

Line Number: 67

这是控制器代码类 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);
}

这是我的模型代码:

   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();
}    
 }

我已经这样做了 $autoload['libraries'] = array('database', 'session'); 所以我不认为这是问题所在。

如果有人知道错误可能是什么,我将不胜感激

4

1 回答 1

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

在这里加载您调用 user_model 的 purchase_model,如果要加载两个模型,请执行以下操作:

$this->load->model('purchase_model');
$this->load->model('user_model');
于 2012-11-17T17:13:47.287 回答