Let's look at the table category
, as an example for the concept I want to understand:
ID NAME PARENT_ID 1 catA 0 2 catB 0 3 childA 1 4 childC 3
What's the best practice to get something organized like this:
array(
'byId' => array(
1 => array(
'name' => 'catA',
'hasChild' => array(
'byId' => array(
3 => array(
'name' => 'childA',
'hasChild' => array(
'byId' => array(
4 => array(
'name' => 'childB',
'hasChild' => false
)
)
)
)
)
)
),
)
);