簡體   English   中英

未定義的屬性:Purchase :: $ purchase_model codeigniter

[英]Undefined property: Purchase::$purchase_model codeigniter

這是我一生中遇到的最奇怪的錯誤,因為昨天它在起作用,今天我醒來卻不起作用,這是錯誤:

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Purchase::$purchase_model

Filename: controllers/purchase.php

Line Number: 67

這是控制器代碼類購買擴展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();
}    
 }

我已經這樣做了$自動加載[“庫”] =陣列(“數據庫”,“會話”); 所以我不認為這是問題所在。

如果有人知道該怎么辦,我將不勝感激

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

在這里加載您稱為user_model的purchase_model,如果要加載兩個模型,請執行以下操作:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM