Doctrine orm 具有多个对象的Doctrine2自定义存储库结果

Doctrine orm 具有多个对象的Doctrine2自定义存储库结果,doctrine-orm,ddd-repositories,Doctrine Orm,Ddd Repositories,我有以下实体: 用户1:n声明响应n:1声明n:1调查1:n用户 如您所见,实体之间的关系在一个圆中是闭合的。我需要用给定用户的回答查询调查的所有报表。并非每一句话都必须回答。结果应该是一个关联数组,如下所示: [ 1 => [ 'statement' => Statement Entity with id 1 'response' => 'Response Entity from the given user of Statement

我有以下实体:

用户1:n声明响应n:1声明n:1调查1:n用户

如您所见,实体之间的关系在一个圆中是闭合的。我需要用给定用户的回答查询调查的所有报表。并非每一句话都必须回答。结果应该是一个关联数组,如下所示:

[
    1 => [
        'statement' => Statement Entity with id 1
        'response' => 'Response Entity from the given user of Statement with id 1
    ],
    2 => [
        'statement' => Statement Entity with id 2
        'response' => null 
    ],
    3 => [
        'statement' => Statement Entity with id 3
        'response' => Response Entity from the given user of Statement with id 3
    ]
]

在自定义存储库中有可能得到这样的结果吗?

您肯定需要两个查询,然后进行合并。查询给定调查的所有报表。然后查询给定用户的语句的所有响应。然后构建您的阵列。你可能一枪就能做到。你试过了吗?