Crawling through a menu tree
I'm working on a light-weight CMS and I have a table of menu items that I want to administer. The relevant fields for this question are
menu_item_id (PRIMARY KEY)
menu_item_status(PUBLISHED, UNPUBLISHED, TRASH)
If there are sub-menus, their menu_item_parent is set to the menu_item_id of the parent menu item. If I change the menu_item_status of a parent, I want the effect to cascade down through all the child menus, however many levels deep.
I tried doing this with a recursive function in PHP but the process would hang on me. I'd rather do it on the level of MYSQL if that's possible. Is there a MYSQL solution for this?
You might also consider using a nested set hierarchical structure for the data instead of the parent/child (adjacency list) structure.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)