Access to libraries in MY_Model |
Hi! I face with problem discussed in this old post and solution never was found.
http://forum.codeigniter.com/archive/ind...844-1.html Funny that in MY_Controller everything is fine. Any suggestions? Maybe someone faced with it too?
Get the CI super object.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(09-27-2015, 04:20 PM)InsiteFX Wrote: Get the CI super object. In CI_Model we have magic method Code: /** So in MY_Model in usual case u dont need get super object cause if u dont have property or method - it will be looking at super object. That is the first note. Second - even if I get super object clearly $CI =& get_instance(); and load library $CI->load->library('my_lib'); when i try to run some method $CI->my_lib->some_method it throws error like i mention before Call to a member function some_method on a non-object in... MY_Model and so on...
Try just loading the library in your controller then call your library methods in your model.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(09-28-2015, 11:01 AM)InsiteFX Wrote: Try just loading the library in your controller then call your library methods in your model. Thats why I write here - I try to load library in MY_COntroller (or Public_Controller or whatever Controller) and in MY_Model i get error describe above. I dont understand why this is working so, but i found the solution. In base MY_Controller I get super object like next: PHP Code: $ci =& get_instance(); After that I can assecc to login and user in any Controller or MY_Model or Model with simple $this->login and $this->_user Thanks for participation in the discussion |
Welcome Guest, Not a member yet? Register Sign In |