Skip to content

Instantly share code, notes, and snippets.

@guilhermeblanco
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guilhermeblanco/11188926 to your computer and use it in GitHub Desktop.
Save guilhermeblanco/11188926 to your computer and use it in GitHub Desktop.
+---------+----------+-----------+
| root_id | toone_id | tomany_id |
+---------+----------+-----------+
| 1 | 1 | 1 |
| 1 | 1 | 2 |
| 2 | 1 | 3 |
| 2 | 1 | 1 |
| 2 | 1 | 2 |
| 1 | 1 | 3 |
+---------+----------+-----------+
$results = array(
0 => array(
'id' => 1,
'toone' => array(
'id' => 1,
'tomany' => array(
0 => array('id' => 1),
1 => array('id' => 2),
),
),
),
1 => array(
'id' => 2,
'toone' => array(
'id' => 1,
'tomany' => array(
0 => array('id' => 2),
1 => array('id' => 3),
),
),
),
);
$results = array(
0 => array(
'id' => 1,
'toone' => array(
'id' => 1,
'tomany' => array(
0 => array('id' => 1),
1 => array('id' => 2),
2 => array('id' => 3),
),
),
),
1 => array(
'id' => 2,
'toone' => array(
'id' => 1,
'tomany' => array(
0 => array('id' => 1),
1 => array('id' => 2),
2 => array('id' => 3),
),
),
),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment