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
You don't need to load the library in the MODEL, MODELS are always called from the CONTROLLERS so you just have to load the Libraries in the Controller, and the functions will be available in the models called from him!
Regards,
Pedro
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With