New to cakephp 3.
I have 3 tables A, B and C. And the relation is
A hasMany B , B hasMany C. I have to apply the query
SELECT A., B.,C.* FROM A
INNER JOIN B ON A.id = B.a_id AND B.active = 1
INNER JOIN C ON C.b_id = B.id AND C.active = 1
WHERE A.active = 1
I need to show the results in the following way.
A title1
B title1
C title1.1
C title1.2
A title2
B title2
C title2.1
C title2.2
The problem is with the result array (or object). I could able to get the data with “matching” function which is same as the above query. But the entire output is coming in single array. Is there any way to get the output in the nested format like
$result = ['A' =>
['title' => 'title1', '
'B' => [
[
'title' => 'title1,
'C' => [
['title' => 'title1.1'],
['title' => 'title1.1'],
]
]
] ;
Now, since its inner join I am getting a single array element for each C row.
Any solution ?