我一直试图用户doctrine2查询构建器没有成功,使用where子句获取相关多对多表中的记录。
我想重现以下声明:
SELECT [...] FROM Company
JOIN CompanyAddress ON CompanyAddress.CompanyId = Company.Id
JOIN Address ON Address.Id = CompanyAddress.AddressId
WHERE Address.State = ?
在google,stackoverfow和doctrine docs上发现了一些意识形态:
$qb = $this->_em->createQueryBuilder();
$qb->select('c')
->from('Company', 'c')
->where(':State MEMBER OF c.Address')
->setParameter('State', $arguments);
但结果不是理想的结果。有帮助吗?感谢..