How would I go about populating a closure table\'s depth/length column when inserting a new node to the tree?
The values in ancestor and descendant are IDs from another
Add depth+1 to the first SELECT.
INSERT INTO closure_tree_path (ancestor, descendant, depth) SELECT ancestor, '{$node_id}', depth+1 FROM closure_tree_path WHERE descendant = '{$parent_id}' UNION ALL SELECT '{$node_id}', '{$node_id}', 0;