Doctrine INNER/LEFT JOIN two tables

前端 未结 1 553
庸人自扰
庸人自扰 2021-01-26 07:46

I am learning from this Question but facing issues with many operations in between:

doctrine 2 query builder and join tables

Below is my Questions. I am looking

相关标签:
1条回答
  • 2021-01-26 08:19

    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.

    0 讨论(0)
提交回复
热议问题