This MySQL query isn’t easy... how can you list ALL descendants of one page? It’s easy to list just the children, but if the tree goes to arbitrary depths, it gets weird. I need a solution that doesn’t require multiple queries or dynamic generation of the query text.... I don’t think such a query is possible though...
This is the easy query (selects Children, i.e. tier 1):
SELECT pagetitle FROM site_content WHERE parent='117';
And I can get Children and Grandchildren using something like this (tiers 1 and 2):
SELECT pagetitle FROM site_content WHERE
parent='117' OR parent in (SELECT id FROM site_content WHERE parent='117');
And then 3 tiers:
SELECT pagetitle FROM site_content WHERE
parent='117' OR parent in
( SELECT id FROM site_content WHERE
parent='117' OR parent in (SELECT id FROM site_content WHERE parent='117') );
I think I just have limit the number of tiers my application can support. The overhead for infinite depth is probably out of the project scope.
Unless someone knows of a way I can pull this off with MySQL so I can use it in a Snippet?
Thanks!