调用未定义的方法Product_model :: product()

时间:2017-09-23 20:09:56

标签: codeigniter codeigniter-2 codeigniter-3

public function save_edit() {

    parent::__save_edit();
    $this->db = $this->load->database('default', true);
    $this->load->model('product_model','',TRUE);
    $id = $this->input->post('item_id');

    $array_item = array(
        'item_name' => $this->input->post('item_name'),
        'note' => $this->input->post('item_note'),
        'stock' => $this->input->post('item_stock'),
        'price' => $this->input->post('item_price'),
        'unit' => $this->input->post('item_unit')
        );

    $this->load->model('product_model');
    $this->product_model->update($id,$array_item);
    redirect('index.php/product');
}

public function edit(){
        $this->db = $this->load->database('default', true);
        $this->load->model('product_model');
        **$data['product'] = $this->product_model->product($this->uri->segment(3))->row_array();**
        $this->load->view('index.php/product_edit',$data);
}

行错误

$data['product'] = $this->product_model->product($this->uri->segment(3))->row_array();

1 个答案:

答案 0 :(得分:0)

你得到这个错误是因为。你的模型,即" product_model "不包含任何产品功能。 因此,你得到"调用未定义的方法Product_model :: product()"错误