Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it bad to use a model directly from a view in codeigniter?

I know normally the data is passed thru to the view with the controller. however, currently in my view I load my model ($this->load->model('Db_model');) so i can use it in a loop to retrieve a users profile picture path from a array of IDs that is passed from controller. Will loading the db model in the view to accomplish this make my site more vulnerable or bad form? To me it seems to be outside of MVC concept but its working atm. thanks

like image 903
jason Avatar asked Feb 27 '23 21:02

jason


1 Answers

I agree, but it has everything to do with scale. If you are designing a tiny app MVC does not really matter because it is easy to oversee the whole application. However once an application starts to grow, or if you are building a bigger application MVC separation becomes more important.

For instance if you use models in your views, this implies the design team has to know about models. It may also hamper porting the views later on to another framework or swapping templates.

like image 120
Gabor de Mooij Avatar answered Mar 09 '23 00:03

Gabor de Mooij