CodeIgniter Forums
Call to undefined method Site_model::userd() I do not get it - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Call to undefined method Site_model::userd() I do not get it (/showthread.php?tid=44000)



Call to undefined method Site_model::userd() I do not get it - El Forum - 07-30-2011

[eluser]Michal1[/eluser]
Hey guys,

I have a problem with function in site controller. I am inserting a data into database and I have an easy function in my controller

Code:
function create_user()
                {
                    $users = array(
                        'username'=>$this->input->post('username'),
                        'password'=>$this->input->post('password')
                    
                    );
                    
                    $this->site_model->userd($users);
                    
                }

Then I have model: site_model and inside

Code:
function userd($users)
        {
            $this->db->insert('users,$users');
            return;
            
        }


Then when I enter data into inputs and click on submit in my view I get this:

Code:
Fatal error: Call to undefined method Site_model::userd() in........

Why? Everything seems fine to me in the code.

Thank you


Call to undefined method Site_model::userd() I do not get it - El Forum - 07-30-2011

[eluser]Bart v B[/eluser]
Did you also load the model in the controller?
some thing like $this->load->model('site_model');

Code:
function userd($users)
{
     $this->db->insert('users',$users);
     return;
            
}



Call to undefined method Site_model::userd() I do not get it - El Forum - 07-30-2011

[eluser]Michal1[/eluser]
I load all models automatically in autoload.php


Call to undefined method Site_model::userd() I do not get it - El Forum - 07-30-2011

[eluser]Ivar89[/eluser]
I don't really see a problem neither, did you check uppercase and lowercase for nameing files and calling them?