Don't think html should be put in your model. What if a new design calls for something other than a list? Or if you want to reuse that function to get the same data elsewhere in your application?
CodeIgniter is an MVC framework, so when building things with it, you should follow MVC architecture. Surely, it would be much better (and more complient with MVC) to get the search results with the model, pass them to ther controller. The controller checks to see if there are any results and then passes it on to the view. You should never use PHP to print out HTML tags, and in Views, you can use if's and loops, so use the view to output and format the data. That would be a more MVC approach.
ddragox , your doing it all wrong. Learn MVC approach before making Codeigniter tutorials. Like all other said, this is wrong. View != Model
Phprs 9 months ago
put view in the model, this is very bad example
markoilic80 1 year ago
why is there display logic in your model?
th1rstyj0n 1 year ago
why put control stuff in a model?
I thought a model should just return data. 1 purpose for 1 function.
MindflowAU 2 years ago
Don't think html should be put in your model. What if a new design calls for something other than a list? Or if you want to reuse that function to get the same data elsewhere in your application?
GamerWho 2 years ago
CodeIgniter is an MVC framework, so when building things with it, you should follow MVC architecture. Surely, it would be much better (and more complient with MVC) to get the search results with the model, pass them to ther controller. The controller checks to see if there are any results and then passes it on to the view. You should never use PHP to print out HTML tags, and in Views, you can use if's and loops, so use the view to output and format the data. That would be a more MVC approach.
ironhamster88 2 years ago
isn`n better to output from model other type of data, like array and, in controller, forward that to view file where is HTML?
vatri89 2 years ago