Используя этот запрос:
$qb = $this->createQueryBuilder('r');
$qb->leftJoin('r.users', 'u')
->addSelect('count(u.id) as user_count')
->groupBy('r.id');
Я получаю набор результатов:
Array
(
[0] => Array
(
[0] => Array
(
[id] => 45
[role_name] => ROLE_ADMIN
[description] => Admin roles
)
[user_count] => 1
)
[1] => Array
(
[0] => Array
(
[id] => 47
[role_name] => ROLE_OPERATOR
[description] => Operator role
)
[user_count] => 1
)
[2] => Array
(
[0] => Array
(
[id] => 48
[role_name] => ROLE_TEST
[description] => ROLE_TEST
)
[user_count] => 0
)
)
Существует ли разумный способ преобразования всех свойств на один уровень?Поскольку сейчас роли находятся в подмассиве с ключом 0.
Желаемый результат:
Array
(
[0] => Array
(
[id] => 45
[role_name] => ROLE_ADMIN
[description] => Admin roles
[user_count] => 1
)
[1] => Array
(
[id] => 47
[role_name] => ROLE_OPERATOR
[description] => Operator role
[user_count] => 1
)
[2] => Array
(
[id] => 48
[role_name] => ROLE_TEST
[description] => ROLE_TEST
[user_count] => 0
)
)