DAO layer with two tables

Asked

Viewed 139 times

0

My doubt when working with the layer DAO next:

As far as I was informed, each table would refer to an object DAO. But suppose it is necessary to make an appointment with select / JOIN that is, that it returns data from more than one table in a single query.

For this case, the object DAO from one table could fetch data from another table?

1 answer

2


Keep it simple, it’s the best thing for future maintenance of an application!

If you need to make one join with another table, choose DAO it makes more sense to effect this relationship.

For example, I have a classe calling for ClientDAO and the other call AddressDAO, and I want to relate the client to their addresses, which may be several, it would make no sense to effect this relationship in the class ClientDAO, because who does the address abstraction and the AddressDAO.

So just pass the properties of the layer Client to the AddressDAO.

related(Client $Client)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.