Welcome Guest, Not a member yet? Register   Sign In
best practice: model or controller?
#1

[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.
#2

[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.
#3

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

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

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

[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




Theme © iAndrew 2016 - Forum software by © MyBB