PHP PDO MySQL如何从特定列中选择所有值并读入数组

I am looking to build a tree from provided data in the form id, name, parent_id, for it to be useful I am looking at changing the direction of the tree to make things easier to iterate through (note: I don't have to then store the info again).

So far I have got

$SQL = "SELECT id, name, parent_id WHERE parent_id = '$parent'";
[execution code]

And I want it to read something like

$tree[<id of parent for tree root, id of children>]['children'] = 
                             array($results[all rows]['id']);

But I have no idea how to go about this I keep reading parts of arrays into the array so I end up with nested arrays which obviously messes up my code,