I'm trying to build a node tree structure of objects with pointers to other objects (parent nodes having pointers to all its children). The input I get is from a mysql database, where each entry has the id of its parent node. So in a way, what I want is to turn the tree around. The code I have is similar to this:
class Node {
var $id;
var $children;
function AddReply($child) {
$this->children[$child->id] = $child;
}
}
Somehow, the update only seems to work for the root node. All the children of all other nodes are lost. And lost, alas, so am I. Could it be that I am unable to update the children-array because there is another pointer pointing to the object I'm accessing?