Welcome Guest, Not a member yet? Register   Sign In
CI4 MVC DB accesses are often made in the controller in the examples
#5

The save() function is part of the model and it’s OK to call it from the controller.
What is not recommended is making SQL queries outside of the model. It will work but it doesn’t follow the MVC pattern and your code will quickly become an unmaintainable mess.
If you need to build a custom SQL query, do it in a new function in the model, or at least in a library. Not in the controllers and not in the views.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply


Messages In This Thread
RE: CI4 MVC DB accesses are often made in the controller in the examples - by includebeer - 01-06-2021, 05:50 AM



Theme © iAndrew 2016 - Forum software by © MyBB