我有一个 Doctrine 1.2 项目,我正在重构它,以便使用具有多个根的教义行为 NestedSet 为表提供树结构。
我需要的是从祖先到后代的继承(不是 OO 常识),其中后代从缺少自己的属性的最近祖先那里继承属性。同样的事情也会发生在关系上。
让我用一个例子来解释:
Category:
actAs:
NestedSet:
hasManyRoots: true
rootColumnName: root_id
columns:
name: string(50)
another_property: string(50)
active: boolean
Tag:
columns:
value: string(50)
CategoryTag:
columns:
category_id: integer
tag_id: integer
我想要执行的是:
- 检索某个类别是否处于活动状态,这意味着验证是否所有祖先都处于活动状态
- 如果给定类别缺少另一个属性,则从存在的最近祖先那里继承它
- 检索给定类别的标签;如果标签丢失,则从最近的祖先处检索它们
为了最大限度地提高速度和灵活性,您建议采用什么最佳方法?