First of, sorry for the vague title.
In our website framework, we have modal classes to represent our database tables, that hold a rows data. I'm currently working on a stat style page, and I'm wondering how other programmers handle linking lots of models together.
For example, on the page, I'm listing all Customers, with there respective Addresses (multiple per Customer. Home, billing, work etc...), and every Order which links to the Customer and Address.
The only options I can think of, are:
- Ditch the models, bring back a raw array from a join query, that has all the data needed.
- Bring back all the different models, and sort them into an array, e.g
$customers[0]['customer'],$customers[0]['addresses']etc... - Create some sort of strange hybrid model that either holds all the data, or holds models.
None of these to me seems particularly ideal, but I don't know of any other ways to do this.
I'm currently using number 2, but I'm curious if there is a different way I could approach this.
Are there any other ways people manage this kind of scenario?