CodeIgniter Forums
Loading not working for models? - 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: Loading not working for models? (/showthread.php?tid=13638)



Loading not working for models? - El Forum - 11-30-2008

[eluser]mattbman[/eluser]
I have just installed CI and for some reason, my models are not properly loading the libraries. Here is my code for my model:
Code:
class Usermodel extends Model {
    
    function Usermodel() {
        parent::Model();
    }
    
    function login() {
        if ($this->input->post('username') && $this->input->post('password')) {
            if ($this->checkpassword($this->input->post('username'),$this->input->post('password'))) {
                $this->session->set_userdata('username',$this->input->post('username'));
            }
        }
        
    }
    
    function logoff() {
        $this->session->unset_userdata('username');
    }
    
    function checkpassword($username,$password) {
        $query = $this->db->query("SELECT * FROM users WHERE username='".$username."'");
        $obj = $query->result();
        $obj = $obj[0];
        if (md5($password)==$obj->password) {
            return TRUE;
        } else {
            return FALSE;
        }
        
    }

}
I need session and database, and I have tried the autoload, I have tried loading in the individual functions, and in the constructor and nothing seems to work. Is there something I am missing?


Loading not working for models? - El Forum - 11-30-2008

[eluser]Thorpe Obazee[/eluser]
It should be accessible from there when you autoload it. Maybe you can paste how you autoloaded it?


Loading not working for models? - El Forum - 12-02-2008

[eluser]mattbman[/eluser]
Nevermind, I got it working again.