0
对于我有2个实体的游戏:故事和story_completed。对于所有用户(这里是公司)的故事是相同的,并且story_completed表示女巫用户已经看过/完成了巫婆故事。现在我想给出一个用户的故事列表,并显示女巫完成,女巫没有完成。ManyToOne加入symfony2
所以,我创建2个实体:
...
table: story
id:
id:
type: integer
generator: { strategy: AUTO }
fields:
name:
type: string
和
...
table: story_completed
id:
id:
type: integer
generator: { strategy: AUTO }
ManyToOne:
story:
targetEntity: Story
fields:
company_id:
type: integer
但现在,如果我做一个JOIN
SELECT s FROM Story s LEFT JOIN s.completed c WHERE ...
我得到一个错误: 错误:Class ... \ Story没有名为completed的关联。
也许我误会manyToOne协会,但我怎么能做到这一点简单的2表连接和加入到doctrine2?事实上,我只需要知道一个故事,如果用户X已经完成它。我不需要收集或双向连接。
我不知道你的图是多么准确,但有一个错误的表名。 “sotry_completed”。另一个问题是,因为关系仅在Story_completed-> Story方向,所以无法在目录Story-> Story_completed中运行查询。看看你的实体,我认为无论如何,使关系成为双向可能更有意义。 –