Welcome Guest, Not a member yet? Register   Sign In
Error with model
#1

[eluser]codebirth[/eluser]
Hello all!

I'm pretty new to CI so probably I'm missing something and this is a dumb question, but sincerely, I can't find what's wrong.

I have this controller

Code:
class Users extends Controller {
    
    function index() {
        $this->load->helper('form');
        $data['main_content'] = $this->load->view('users', '', true);
        $this->load->view('global', $data);
    }

    function login() {
        $this->load->model('Login_model', TRUE);
        if ($this->Login_model->user_exists($this->input->post('email', TRUE), md5($this->input->post('password', TRUE))))
            $data['main_content'] =  "ok";
        else
            $data['main_content'] = "error";

        $this->load->view('global', $data);
    }
}

and here is the model

Code:
class Login_model extends Model {

  function Login_model()
  {
    parent::Model();
    }

    function user_exists($email, $password) {
        return true;
    }
}

When I try to login I get this error

Quote:Fatal error: Call to a member function user_exists() on a non-object

What I'm doing wrong? Any help will be appreciated.

codebirth
#2

[eluser]xwero[/eluser]
$this->load->model('Login_model','', TRUE);
#3

[eluser]codebirth[/eluser]
Thanks xwero! Smile
#4

[eluser]ELRafael[/eluser]
Welcome codebird

you can remove "true" if you pass only 1 arg to method

Code:
$this->load->model('Login_model');
#5

[eluser]codebirth[/eluser]
OK ELRafael. Obrigado!




Theme © iAndrew 2016 - Forum software by © MyBB