我有两个相关的表。其中一个表与第二个表有一对多的关系。这是两个表的样本图解Symfony Doctrine - 使用外键字段从相关表中检索记录
**
registration
id | firstname | membershipfk
1 | John | 2
2 | Foo | 3
**
这里是第二个表的说明
membership
id | type | discount | description
1 | Gold | xyz | xyz description
2 | Silver | xyz | xyz description
现在我目前的挑战是检索成员资格表中的成员字段使用注册表中的外键。 例如:Select Type, Discount and Description from Membership Entity where fk in registration entity is equal to 2
目前在我的控制,我做这样的尝试
public function getMembersAction()
{
$restresults = $this->getDoctrine()->getRepository('XXXBundle:Members')->findAll();
$data = array();
foreach ($restresults as $restresult) {
array_push($data, $this->serializeData($restresult));
}
每一种援助深表感谢
请什么WEEL – blend
遗憾的错误,它很好,你需要配置实体之间的关系。请参阅主旨文件请@blend –
关系已配置 – blend