If you read a row from DB using ORM and passing that object to a view then in a view you would do something like $object->field to access a certain field.
What if this view is called in another controller where the row is fetched using Database class with DB::select()->execute()? In this way $object->field would not work anymore...
How do you pass data to the view so that view can access data in the same way?
Second question. Can ORM use Database query builder methods for filtering out data (or_where, and_where and so on)?
Harro Verton wrote on Thursday 19th of January 2012:
Use a Viewmodel to unify the data?
Ok this was my first thought, but what when I am passing an array of record from db? Isn't this then doing double work? First iterating trough array of results/objects in Viewmodel to unify the data, and then iterating again in View to outpu the data? This also unecessary extends the execution time...?! Am I wrong?
Well, it's your choice to retrieve data in different formats.
Alternative is to deal with this in your model, and make sure the results are returned in the same format.
But in the end, whether you do it in your model, controller, viewmodel or view, you'll have to convert.