Well guys, I have three tables here, menu, user and access. For simplifying let’s consider:
- User table has one column: id
- Menu table has 5 columns: id, title,
url, lft, rgt - Access table has 4 colums: id,
user_id, menu_id, access
I’m using SitePoint’s Modified Preorder Tree Traversal to display the menu:
SELECT id, title, lft, rgt, url FROM menu WHERE lft BETWEEN 3 AND 49 ORDER BY lft ASC;
In the access table, the access column is having values of 0 or 1. At the same time, on a given page, I have the id value of User table, say $id.
The idea is modify the above select to show only those menu items, where in the corresponding Access table, the access column is set to 1. Where access = 0, the menu doesn’t turn up for the given user.
Have I been clear? Thanks in advance for any help.
Cheers.
select id, title, lft, rgt, url from menu join access on (menu.id = access.menu_id) where (lft between 3 and 49) and access.access=1 order by lft asc;