CodeSlayer
CodeSlayer

Reputation: 1329

Loading model of codeigniter

I have a problem loading a model, i have code like this

function __construct() {
    $this->load->model("admin_model");
    parent::__construct();
}



function login() {

  $log = $this->admin_model->login($username, $pass);

}

if i use the code above, i get this error A PHP Error was encountered

Severity: Notice

Message: Undefined property: admin_controller::$admin_model

Filename: controllers/admin_controller.php

Line Number: 43


Fatal error: Call to a member function admin_login() on a non-object in   C:\xampp\htdocs\ci\application\controllers\admin_controller.php on line 43

Upvotes: 0

Views: 55

Answers (1)

user3954526
user3954526

Reputation:

Put this code on top of your function parent::__construct();

Upvotes: 1

Related Questions