I am trying to limit the number of queries I hit the database with -- so rather than running a PHP loop I want to write on more complex SQL.
-> ParentThreadID (can be unlimited levels deep)
-> more rows that don't matter
-> Level (0 - No Accress, 1 - Read, 2 - Write, 3 - Write & Manage)
So permissions are inherit. So say there is thread structure like this.
ID - Name - ParentThreadID
1 - Home - 0
2 - Sub of "Home" - 1
3 - Sub of "Sub of Home" - 2
ID - ThreadID - IntranetGroupID - Level
1 - 1 - 1 - 3
ID - GroupName
1 - Example
So permissions are inherit so any user in Example group should have "Write & Manage" permission to Home, Sub of Home, and Sub of Sub of Home.
I want to do 1 single sql query that shows any user who can see Sub of Sub of Home. Since it's not necessarly registered to a particular thread ID it's hard to do this with one query.
I do this twice -- once for specific users and once for groups so if I save a lot of queries for Groups, I will save them for Users too.
Is this possible? Any help would be appreciated.
Thanks in advance.