如何使用Symfony和Doctrine Query Builder执行连接查询
- 论坛
- 如何使用Symfony和Doctrine Query Builder执行连接查询
21 浏览
如何使用Symfony和Doctrine Query Builder执行连接查询
我有两个通过1:1关系连接的实体,例如:MyEntity.idRelatedEntity
我想创建一个Doctrine查询,根据RelatedEntity
中某一列的值从MyEntity
中检索数据。类似这样(当然这个例子不起作用):
$entity = $em ->getRepository('MyBundle:RelatedEntity') ->createQueryBuilder('e') ->leftJoin('MyBundle:RelatedEntity', 'r') ->where('r.foo = 1') ->getQuery() ->getResult();
非常感谢您的帮助 🙂