Created
August 21, 2019 14:09
-
-
Save jaynarayan89/563b9b5943761f330d62ea8d7728c1fb to your computer and use it in GitHub Desktop.
closure table tree query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function getTree($root, $level = 3) | |
{ | |
$nodes = DB::select( | |
' | |
SELECT | |
members.id, | |
members.first_name, | |
members.leg_side, | |
members.parent_id | |
FROM members | |
JOIN binary_plan_tree_paths ON members.id=binary_plan_tree_paths.descendant | |
WHERE binary_plan_tree_paths.ancestor=? | |
AND binary_plan_tree_paths.depth < ?', | |
[$root,$level] | |
); | |
return $nodes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment