Why won’t my model load the encryption library?
class User_model extends Model {
function User_model() {
parent::Model();
$this->check_login();
}
function check_login() {
$this->load->library('encrypt');
$email = $this->encrypt->decode($email);
....
}
}
This giving me a PHP error: Call to a member function decode() on a non-object on line X — where X is the $this->encrypt->decode($email); line?
Edited to show that the problem was that check_login was called from the constructor
I was calling check_login from within the constructor, and that was causing the problems.
The solution is to call
$this->_assign_libraries();right after loading a library in a constructor.Thanks to this codeignitor forum thread:
http://codeigniter.com/forums/viewthread/145537/