[eluser]Unknown[/eluser]
Hi all,
I'm using left join on a request, it list all categories and all products in each category, the problem is that the result is a dispatched array and i want something like below:
$res = [
[
"category_id" => "1",
"name" => "bar",
"products" => [
[
"product_id" => "1",
"name" => "bar_p_1"
],
[
"product_id" => "2",
"name" => "bar_p_2"
]
]
],
[
"category_id" => "2",
"name" => "foo",
"products" => [
[
"product_id" => "1",
"name" => "foo_p1"
]
]
],
[
"category_id" => "3",
"name" => "other",
"products" => [ ]
]
]
Does someone knows how to do that ? Thanks