vendredi 24 avril 2015

Testing thousands of similar fields for differences

I have created a privilege system for my application which allows/disallows access to specific pages based on user input.

The table looks something like this:

page_id | client_id | sys_group_no | name | friendly_name | viewable |

   1    |     4     |       1      | home |     Home      |   true   |
   2    |     4     |       1      | admin|   Admin Home  |   false  |

So if the user in client_id 4 is of group 1 they are NOT allowed to view 'Admin Home' it isn't actually quite this simple but for the sake of this question we can pretend.

The problem is as maintenance goes on this table get out of date quickly, and when you have a few thousand rows, constantly checking the table against the actual page names (using scandir() and array_diff()) will be expensive. Is there a different paradigm for checking this kind of integrity other than direct comparison? - For instance would hashing my $page_array and comparing it be a better approach?

Aucun commentaire:

Enregistrer un commentaire