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.
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报