Milbhen Bars Milbhen Bars - 2 months ago 4
PHP Question

Fatal error: Call to undefined method codeigniter

Please help me. I've tried to solve it, but what is the problem in my code? This is my first time to encounter this error. I really need help, please.

This is the error I'm getting:

Fatal error: Call to undefined method supp_model::getsuppid() in C:\wamp\www\minimart\application\controllers\minimart.php on line 19


Here is my library:

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


My Model:

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

}

Answer
 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); 
    }
Comments