[英]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 { 这是控制器代码类购买扩展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 : 在这里加载您称为user_model的purchase_model,如果要加载两个模型,请执行以下操作:
$this->load->model('purchase_model');
$this->load->model('user_model');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.