因此,我想使用ResultSetMapping
获取已经准备好的数据数组。现在我只得到field => value
例。我如何获得
'alias' => [
'field1' => 'value1',
'field2' => 'value2',
],
...
How I retrieve now:
$rsm = new ResultSetMappingBuilder($this->em);
$rsm->addScalarResult('uuid', 'uuid');
$rsm->addScalarResult('date', 'date');
// here need to provide somehow common index "employee"
$rsm->addScalarResult('employeeUuid', 'employeeUuid');
$rsm->addScalarResult('employeeFullName', 'employeeFullName');
// here need to provide somehow common index "pathwayPatient"
$rsm->addScalarResult('pathwayPatientUuid', 'pathwayPatientUuid');
$rsm->addScalarResult('pathwayPatientTitle', 'pathwayPatientTitle');
所以我期望下一个结构:
$result = [
'uuid' => $row['uuid'],
'date' => $row['date'],
'pathwayPatient' => [
'uuid' => $row['pathwayPatientUuid'],
'title' => $row['pathwayPatientTitle']
],
'employee' => [
'uuid' => $row['employeeUuid'],
'fullName' => $row['employeeFullName']
]
];
关于如何以这种方式获取内容的任何想法?当然,除了写foreach
并满足我的所有需求:)