Doctrine INNER/LEFT JOIN two tables

杀马特。学长 韩版系。学妹 提交于 2019-12-02 10:03:35

The complex part of you query is actually the WHERE so you should be able to just add the joins with little issue.

$qry = $this->manager()->createQueryBuilder()
        ->select(array('e', 's', 'a'))
        ->from($this->entity, 'e')
        ->leftJoin('e.sources', 's')
        ->leftJoin('s.node', 'a');

And then you would do the rest of your query logic as is pretty much.

The one thing that needs to be mentioned is that in DQL you are dealing with Entities and their properties as opposed to tables and columns.

So in my example e.sources needs to be the mapped property name for the UserSource entity/collection on your User entity. Likewise, s.node needs to be the mapped property name of the Area entity/collection on UserSource.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!