Hello everyone,
im trying to implement the Data Gateway / Domain Pattern. I understand the basics and its a fantastic pattern to separate domain logic from the persistent data layer. Now i have following requirement:
Lets say i have 2 domain-models: User(s) and Company(ies). When i wanna retrieve a user list with all users, i would do something like that:
$userGateway = new Model_UserGateway();
$users = $userGateway->fetchAll();
foreach ($users as $user) {...}
that works very fine, but now the tricky part: I wanna now have a List with all users and their corresponding company. I could iterate through the users and instance for each user the related company, but that... isnt my favourite solution. In the worst case i produce nested database queries. Another approach would be, that i fetch additional user data with the gateway and deal with them... i dont know :(
Whats the best praxis to get a user list with the company info?
thanks in advance
Michael M