I have a database with a table named 'Items', that have a few simple attributes. Let's assume it looks like so:
ID Name IsEdible -- ---- -------- 1 Apple 1 2 Chair 0 3 Bread 1
Let us also assume that we want to print this data out to the screen like so:
Item Is this edible? ---- --------------- Apple Yes Chair No Bread Yes
Now, the MVC pattern basically says that this should happen:
- The controller is instantiated
- The controller asks the model for the data
- The controller reads in the template (the view)
- The controller replaces the placeholders in the template with the data it got from the model
- The controller sends (serves) this result to the end user
All pretty simple. My question is this: At some stage, the column IsEdible has to be converted from bit value (1/0) to a string value (Yes/No). Should the model be doing this, or should the controller be doing this? In other words, should the formatting of the data be handled by the model, or just the data retrieval?
I know it's a nit-picky question, but I feel this is a core concept of MVC that I'm unsure of.
This post has been edited by e_i_pi: 02 September 2011 - 08:30 PM