PDA

View Full Version : Quick Question about if this method is a good one.


Morgoth
08-19-2003, 03:47 AM
First off, on my site, I wanted a good method so that the staff members on the site have specific access to what I tell them to have.

I was first thinking of just a simple field beside their account name in the database that gave them a rank.
Example:
0 - No Privileges
1 - Poll Privileges
2 - Posting Privileges
3 - blah blah...

So if you had the privilege of 2, you had everything below, and if you had 3 you had everything under that. Simple...
But I didn't want that, I needed to make a method where I can select privileges for users without them having others.

I didn't want to create more fields, so I created one new field, and I am using binary to tell the staff member what he can do.
1101
^
The first digit is poll
second is posting
third is blah blah
fourth is meh...

And all I do is Select the field, and just find out if the digit number this script requires is 1 or 0 (true or flase).
blnVariable = Mid(oRS("UserPrivileges"),2,1)

Do you think this is a fast and easy method, or should I just make many different true or false fields in my database?

raf
08-19-2003, 08:00 AM
I never had good experiences with 'composid-value-fields'. I doesn't look easy to maintain and select on either. How are you gonna update that?
if mid(rswhatever.Fields,1,1) = 1 then
blabla=original - 1000
etc

I'd vote for multiple fields, since it's easier, less confusing and probably faster. If you really need to keep the table as small as possible (or if you maximaly need to avoid redundancy, then build a new permissionstable where you have the different fields + a primary key. And only include the PK in your current table as a foreign key. For some pages you could select on the keyvalue itself (for instance if only one specific profile can see the page) and for other you need a join with this small table.

Morgoth
08-19-2003, 08:32 AM
Yeah it may get confusing, but originally it was going to use a different system.
The field is basically an array.
String1 = 1101
Split(String1, ",")

I don't know... I might go back. It will get really confusing in the future.