【发布时间】:2019-01-22 01:53:00
【问题描述】:
我有 AdminFiles 实体,它保存所有项目实体(新闻、页面、事件等)的文件。它的结构(删节)如下:
id int(11) Auto Increment
entity varchar(255) // this holds the entity name, e.g. Page or News
entity_id int(11) NULL // this holds the entity ID
filename varchar(1000) // this holds the path to the file
我希望使用 $entity->getFiles() 之类的方式访问实体(页面、新闻等)中的文件。但是我在创建关系时遇到了麻烦,因为它不仅受 ID 的约束,还受实体名称的约束。有什么方法可以在 Doctrine2 实体中加入这个,还是我必须在服务中这样做?
【问题讨论】:
标签: database doctrine-orm entity-relationship