duandaoji3992 2009-08-09 15:15
浏览 29
已采纳

一个大DAO还是多个小DAO?

If I have to save an object to the database which has a relationships, do I have that dao do all the saving itself, or to delegate to other DAO's. If it should delegate to other DAOs, should that be done in the DAO itself, or in a layer above (like a service layer)? I would use an ORM for this, except that in PHP, nothing good exists yet.

  • 写回答

2条回答 默认 最新

  • doucheng7234 2009-08-09 15:22
    关注

    I think the answer depends on ownership.

    If the Parent owns the Children, and there's no possibility of creating a Child without a Parent, then it should be just ParentDao and no ChildDao at all.

    If you can create a Child without a Parent, you'll need a ChildDao for its CRUD operations. In that case, you could have the ParentDao own a reference to a ChildDao and defer Child CRUD operations to it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?