Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. ancestor descendant depth
  2. 1 1 0
  3. 1 2 1
  4. 1 3 1
  5. 1 4 1
  6. 2 2 0
  7. 3 3 0
  8. 4 4 0
  9.  
  10. INSERT INTO closure_tree_path (ancestor, descendant)
  11. SELECT ancestor, '{$node_id}' FROM closure_tree_path
  12. WHERE descendant = '{$parent_id}'
  13. UNION ALL SELECT '{$node_id}', '{$node_id}';
  14.  
  15. INSERT INTO closure_tree_path (ancestor, descendant, depth)
  16. SELECT ancestor, '{$node_id}', depth+1 FROM closure_tree_path
  17. WHERE descendant = '{$parent_id}'
  18. UNION ALL SELECT '{$node_id}', '{$node_id}', 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement