I would like to create a query with join
using queryBuilder
. I would like to get the result from it in a multidimensional array, like in this answer: https://stackoverflow.com/a/15088250/3042117
Unfortunately I get just one dimensional array as a result. Like [UserCrediHistory,UserInstance,UserCreditHistory,UserInstance....]
How to get the result in this format?
array(
array(
0 => UserCreditHistory instance,
1 => Userinstance,
),
array(
0 => UserCreditHistory instance,
1 => Userinstance,
),
// ...
)
My code looks like this:
$qb->select(array('ow', 'us', 'it'))
->from('\\Entities\\MyItem', 'it')
->innerJoin(
'\\Entities\\User',
'us',
\Doctrine\ORM\Query\Expr\Join::WITH,
'it.user = us.id'
)
->innerJoin(
'\\Entities\\User',
'cr',
\Doctrine\ORM\Query\Expr\Join::WITH,
'it.owner = ow.id'
);
I tried to change the hydration mode, or call getArrayResult()
, but it's still the same