CodeIgniter Forums
do i need to load the model again and again? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: do i need to load the model again and again? (/thread-69138.html)



do i need to load the model again and again? - nadeem14375 - 10-12-2017

Is there any way to load a model once? 

I am experiencing with error:

Quote:Message: Undefined property: CI_Loader::$Users_model

when call for a view in my controllers.

loading the model solve it.

but do I need to load the model before any call to a view?

another error which is disappear 


Quote:Message: Call to a member function get_user_info() on null

I don't think its right way to load mode again and again.


RE: do i need to load the model again and again? - ChicagoPhil - 10-12-2017

(10-12-2017, 07:55 PM)nadeem14375 Wrote: Is there any way to load a model once? 

I am experiencing with error:

Quote:Message: Undefined property: CI_Loader::$Users_model
when call for a view in my controllers.

loading the model solve it.

but do I need to load the model before any call to a view?

I don't think its right.

You only need to load a model if you are using it. If you use the model on every request you should auto-load the model.


RE: do i need to load the model again and again? - nadeem14375 - 10-12-2017

(10-12-2017, 08:01 PM)ChicagoPhil Wrote:
(10-12-2017, 07:55 PM)nadeem14375 Wrote: Is there any way to load a model once? 

I am experiencing with error:

Quote:Message: Undefined property: CI_Loader::$Users_model
when call for a view in my controllers.

loading the model solve it.

but do I need to load the model before any call to a view?

I don't think its right.

You only need to load a model if you are using it. If you use the model on every request you should auto-load the model.

you mean to add in autoload.php?


RE: do i need to load the model again and again? - ciadvantage - 10-12-2017

I think you should load it in function __construct() then it should be fine. That is how I use