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

It sure looks like unexpected behavior.
If I do this in a view:
PHP Code:
//$records is the result from my model, passed by the controller
Echo '<pre>';
Foreach(
$records as $record) {
 
   Print_r($record); 
   Echo '<hr>';

}
Echo 
'</pre>; 
I get the data from all individual records, separated by a horizontal line.
If I would pass $record to a function, only THAT record will be passed, not the complete set of records.
My advice is not to use your own objects, but the objects CI provides for.
If your function has database operations, put it in a model.
If there's no database operation, put it in a library.
If it's a simple operation that doesn't need OOP approach, put in a helper.
In all cases, load the model, library or helper in your controller.
Use $this->model_name->function_name(), or $this->library_name->function_name() or $this->helper_name->function_name() to call the approriate function.
Reply


Messages In This Thread
RE: model in view, or passing from view strange behavior - by Wouter60 - 10-29-2019, 09:14 AM



Theme © iAndrew 2016 - Forum software by © MyBB