Welcome Guest, Not a member yet? Register   Sign In
Model / Controller access
#1

Fairly new to using CI, and this is probably a stupid question, but I figured I'd ask, because the answer didn't seem 100% apparent to me.




What is the proper  way of globally initiating a new model for use throughout a controller ?   or do I need to do a $model = new someModelname();  in each function that I want to access the model from ?

Do I just drop it in something like the index function, and call it from my other functions using $this->index()->model->SomeModelFunction   



Thanks,
Reply
#2

Take a look at this documentation article and learn how to extend every controller and make variables and methods available in every inherited controller:

https://www.codeigniter.com/user_guide/e...controller
Reply
#3

(12-25-2020, 04:59 PM)John_Betong Wrote: Take a look at this documentation article and learn how to extend every controller and make variables and methods available in every inherited controller:

https://www.codeigniter.com/user_guide/e...controller

Well damn... I missed that in the documentation..   Now I feel silly...  lol    Thank you !
Reply




Theme © iAndrew 2016 - Forum software by © MyBB