how's models loaded should be in MVC pattern? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: how's models loaded should be in MVC pattern? (/showthread.php?tid=22388) |
how's models loaded should be in MVC pattern? - El Forum - 09-08-2009 [eluser]metaltapimenye[/eluser] soory for my english.. when i got latest version of CI (1.7.1), i realize there's something change with models load protocol even it might be happen long on older versions. when i do this in my model, some coding style meet its limitation.. Code: //location:/application/models/one.php for short term project it would not be a problem, but if we working a huge and long term project .. it might make some models wont work after upgrade, and yes, it could be a pain in the ass to fix it. yesterday, i make some tryouts on CI 1.7.1 Controller: Code: class Blog extends Controller { View: Code: <!--html stuff--> it would be a pleasure for an old cowboy like me to applying this coding style. But i reminded by the way loading model->model and i might pissed when i upgrade which is not allow me to do some stuff like this way. in best practice, how's models loaded should be in MVC pattern? how's models loaded should be in MVC pattern? - El Forum - 09-08-2009 [eluser]Phil Sturgeon[/eluser] Why are you using Models to output headers and footers? Models should not return HTML but should fetch and manipulate data from database, XML, REST, etc. HTML should go into views. If you wish to load one model from another, do this: Code: class one extends Model { how's models loaded should be in MVC pattern? - El Forum - 09-08-2009 [eluser]BrianDHall[/eluser] Yes, Phil is right on all counts, but I figure I will add a little extra info to let you know why yours isn't working. In a Model $this refers to the object Model, not to the main CI object that $this refers to in Controllers and Views. This drove me nuts when I was trying to update sessions from a Model for authentication purposes, and Phil's solution is the right one. |