CodeIgniter Forums
best practice: model or controller? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: best practice: model or controller? (/showthread.php?tid=9634)



best practice: model or controller? - El Forum - 07-02-2008

[eluser]satterle[/eluser]
I am taking a mySQL date (2008-07-02) and breaking it apart to populate form elements, one for year, one for month and one for day using strtok function. Question: is it best practice to split the date in the model function or in the controller function, or is this an either/or thing? Currently I'm splitting the date in the controller.


best practice: model or controller? - El Forum - 07-02-2008

[eluser]Bramme[/eluser]
It's really how you like it best. If you only need to do this once, you could keep it in your controller, if you need to do this several times, Don't Repeat Yourself (DRY, keep that in mind Wink) and put it in a library, model or helper, whatever suits your needs.


best practice: model or controller? - El Forum - 07-02-2008

[eluser]satterle[/eluser]
Thanks! DRY == KISS? ;-)


best practice: model or controller? - El Forum - 07-02-2008

[eluser]Bramme[/eluser]
KISS? Never heard off... As I'm guessing you're not referring to the band.


best practice: model or controller? - El Forum - 07-02-2008

[eluser]Pascal Kriete[/eluser]
Keep it simple, stupid. They're related, but not the same Smile .


best practice: model or controller? - El Forum - 07-02-2008

[eluser]xwero[/eluser]
to get back on topic why not break it in sql
Quote:SELECT day( date ) day ,
month( date ) month ,
year( date ) year
FROM table