Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8312549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:12:07+00:00 2026-06-08T20:12:07+00:00

I’m trying to implement a table row permission system in my database (with a

  • 0

I’m trying to implement a table row permission system in my database (with a PHP front-end and MySQL back-end). It should follow the Windows File Permission system, in the sense that:

  • There are users
  • Each user can be a member of several groups
  • Each group can be a member of other supergroups
  • You can specify an entire group, supergroup or a single user for
    permissions
  • Should be: User permission supercedes subgroup supercedes supergroup. (<- not entirely necessary)

The user, after creating the database entry, can specify which groups/users should have which permissions (read, write or leave invisible). When accessing the web front-end, only the entries which they have permissions on should be displayed (using a cookie login system). Only those which they have Write access to should be available for editing.

Basically, I don’t know how to efficiently create the database to relate the user to the permissions they should have on the file (I know, once I get the permission ‘level’, how to do the rest of course).

I’ve tried relation tables, but that got complicated very fast. I tried arrays of User/Group IDs in the file entry itself (as a field for the file), but this was sloppy and only supported 64 entries (as well as being difficult to implement the group/user heirarchies).

Are there any examples, add-ins, anything to help with this? I’m versed in Javascript, PHP, SQL, HTML and their relationships and I’m re-writing an old version using the new PDO extension. I know it’s in the realm of possibility, but every stratagy I’ve tried has just been a nightmare.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T20:12:11+00:00Added an answer on June 8, 2026 at 8:12 pm

    If you were using Oracle, you could use role functionality to deal with the hierarchy of groups. Mysql doesnt currently offer this functionality (although it seems to be on a list to do here ).

    In the meantime, you could mimic this functionality something like this.
    Create a table called roles which has id and name fields and populate with a set of roles.

    enter image description here

    Create a table called user_role_privs that will hold the direct links from users to a role.

    enter image description here

    and create a table called role_role_privs that holds roles that are granted other roles

    enter image description here

    Finally, we add a table that we want to only be accessed by certain privileges so we add the columns we want plus one for the role that can view this data.

    enter image description here

    and then we create a new view which uses the data in the role tables plus the current_user() function to determine what data can be displayed.

    create or replace view user_student 
        as select s.id, s.name, s.age
            from user_role_privs urp, student s 
           where urp.user=current_user() 
             and urp.role=s.role
           union 
          select s.id, s.name, s.age
            from user_role_privs urp, role_role_privs rrp, student s
           where urp.user=current_user()
             and urp.role=rrp.role_id
             and rrp.granted_role=s.role
    

    Now if your php allows user1 to login, they will select from the view and see the following data – that is Pluto is seen based on the direct role grant and Mickey and Donald because the role of clerk is granted to the role of Manager.

    But if user2 logins, They will only see the records directly granted to their role of Clerk which are Mickey and Donald.

    So if your application selects data from the user_student role instead of the student table, it would provide read access.

    To do write access based on the role, you would probably need to extend this idea to include an edit flag on the role table and only show an edit button and related functionality if the role permitted it.

    A role should have access to edit any data it can see so you keep the code simpler by creating more roles if needed. For inserts into the table, you may also need a before insert trigger, to insert a role of the user that created it in the student.role column. You would have to decide if this should be the role with the highest or lowest privileges as this then grants other users access as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.