2009-12-14 18:46
浏览 66

Doctrine - 检索子类中的字段列表会聚合所有字段

I have an object model that contains a class with several subclasses. The subclasses share a few fields from the parent, but they each have their own fields as well.

I'm using the column_aggregation inheritance type to do this because I want to be able to polymorphically store objects of the parent class type, but retrieve objects of the subclass types.

So far, I can retrieve the objects with their subclass types intact. My problem is that when I call getColumns() on any of the subclass , I get all the fields for the aggregated table, so I see every field from all the subclasses together.

Is there a way to only get the fields that actually belong the subclass?

图片转代码服务由CSDN问答提供 功能建议

我有一个包含具有多个子类的类的对象模型。 子类与父级共享一些字段,但它们每个都有自己的字段。

我正在使用column_aggregation继承类型来执行此操作,因为我不想以多态方式存储父类 type的对象,而是检索子类类型的对象。

到目前为止,我可以检索其子类类型完整的对象。 我的问题是,当我在任何子类上调用getColumns()时,我会记住聚合表的所有字段,所以我看到来自 all子类的每个字段。

有没有办法只获取实际属于 subclass的字段?

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dslkchyv673627 2009-12-23 18:11

    Design-wise the output of getColumns() is correct (it merely returns all columns of the aggregated table). I think Doctrine_Table->getColumns() is oblivious to the fact that the table in question has sub-classes. Try to use Doctrine_Table->getColumnDefinition() or as a last resort Doctrine_Table->getColumnOwner($column) to infer which columns belong to which sub class.

    解决 无用
    打赏 举报

相关推荐 更多相似问题