[eluser]gfraser99[/eluser]
I am wondering what the best practice is for formatting data query results, as in should this be done in the model, controller or view. Here is the exact example I am dealing with.
I want to populate a select list which takes an array with 1 key and 1 value to populate.
Code:
Array
(
[1] => 'apples'
[2] => 'oranges'
)
My model query result returns all records and all columns:
Code:
Array
(
[0] => Array
(
[id] => 1
[name] => 'apples'
)
[1] => Array
(
[id] => 5
[name] => 'oranges'
)
)
The array I need to pass to my view does not match the format my model returns the data in.
1. Should I build another model method to return only the data I need?
2. Should I format the returned data to the array format I require to populate my select list in my view within the controller?
3. Should the logic be built in the view?