model in view, or passing from view strange behavior |
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? |
Messages In This Thread |
model in view, or passing from view strange behavior - by Goddard - 10-25-2019, 10:46 AM
RE: model in view, or passing from view strange behavior - by Wouter60 - 10-25-2019, 12:29 PM
RE: model in view, or passing from view strange behavior - by Goddard - 10-28-2019, 05:32 AM
RE: model in view, or passing from view strange behavior - by Wouter60 - 10-28-2019, 12:44 PM
RE: model in view, or passing from view strange behavior - by Goddard - 10-29-2019, 07:26 AM
RE: model in view, or passing from view strange behavior - by Wouter60 - 10-29-2019, 09:14 AM
RE: model in view, or passing from view strange behavior - by Goddard - 10-29-2019, 10:19 AM
RE: model in view, or passing from view strange behavior - by Wouter60 - 10-29-2019, 11:08 AM
RE: model in view, or passing from view strange behavior - by Goddard - 10-30-2019, 05:19 AM
|