![]() |
BaseController load, use model example - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forum-30.html) +--- Thread: BaseController load, use model example (/thread-77574.html) |
BaseController load, use model example - MrPeterman - 09-18-2020 I have a model that performs some operations in my database. We'll call it "Somemodel". There's a method I want to use called "somemethod($value)" in the Somemodel model. I'd like to include this model and call that method in every controller. I know that I can modify the BaseController, and all my controllers should extend BaseController. Can someone show me an example of what that looks like? The documentation shows using a Session service. So, what does the code look like to load one of my models? Code: // Do Not Edit This Line RE: BaseController load, use model example - InsiteFX - 09-19-2020 There is a helper that you can use that makes it a lot simpler. PHP Code: // Create a new class manually CodeIgniter 4 User Guide - Using CodeIgniter’s Model RE: BaseController load, use model example - MrPeterman - 09-19-2020 Thank you, InsiteFX! That was exactly what I needed. (I tried to "+Rate" your post, but Chrome wouldn't have it). I greatly appreciate your response. |