请帮帮我。我试图解决它,但我的代码中的问题是什么?这是我第一次遇到这个错误。我真的需要帮助。
这是我得到的错误:
Fatal error: Call to undefined method supp_model::getsuppid() in C:\wamp\www\minimart\application\controllers\minimart.php on line 19
这是我的图书馆:
class minimart extends CI_controller { //myclass
function __construct()
{
parent::__construct();
}
function supplier()
{
$this->load->model('supp_model');
$id = $this->uri->segment(3);
$mini['allrecords']= $this->supp_model->getsuppid($id); //this line give me an error
$this->load->view('view_supplier.php', $mini);
}
我的模特:
class supp_model extends CI_Model {
function getsuppid($id) //the function exist
{
$this->db->select('*');
$this->db->from('supplier_table');
$this->db->where('supplier_code ', $id);
$q = $this->db->get();
$result = $q->result();
return $result;
}
}
答案 0 :(得分:1)
function __construct() {
// Call the Model constructor
parent::__construct();
$this->db = $this->load->database('default', true);
}
function supplier()
{
$this->load->model('supp_model',true);
$id = $this->uri->segment(3);
$mini['allrecords']= $this->supp_model->getsuppid($id);
$this->load->view('view_supplier.php', $mini);
}