Welcome Guest, Not a member yet? Register   Sign In
model in view, or passing from view strange behavior
#4

It's bad practice to call a model function from a view.
Typically, a model is used to retrieve information from your database. You should call the model inside your controller, not inside a view.
After you've retrieved the data, pass it to the view to display it in your browser.

If you need some repetitive action inside your view, you can simply create a php function inside the view itself, or create your own helper and load that (before you open the view).
Have a look at the helper documentation here: https://codeigniter.com/user_guide/general/helpers.html

In your case, it's all about the $db_object variable that is processed by the function.
According to the function, it is an array, because you have a foreach ... structure to loop through it's elements.
So my question is: what do you pass to the function, and what do you expect as it's return value?
Reply


Messages In This Thread
RE: model in view, or passing from view strange behavior - by Wouter60 - 10-28-2019, 12:44 PM



Theme © iAndrew 2016 - Forum software by © MyBB