icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.

» Surpass Web Hosting Forums » Discussions » PHP, MySQL » Multiple Flags not sure what to do

PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >>

Closed Thread
 
LinkBack Thread Tools Search this Thread Rate Thread
Old July 17th, 2003, 9:34 AM   #1 (permalink)
Registered User
Seasoned Poster
 
Joined in Jul 2003
Lives in Research Triangle Park, NC / Blacksburg, VA
57 posts
Gave thanks: 0
Thanked 0 times
In my database of users they have 6 privledges that I can either set or unset. That leaves 2^6 combinations so I don't really want to establish a "level" system since there isn't any logical hierarchy of user privledges -- pretty ad hoc.

My convention in a situation like this would be to whip out my old C trick of using a hexadecimal number with 6 of the bits (ranging from 0x01 to 0x37) and storing that with a binary &, then pulling the fields out with a binary |.

Is there a better way to do this while storing these values in the MySQL database? Having 6 enums in the database seems a bit inefficient, but it might have some advantages with using SELECTS against certain privledges.

Just wondering what some experienced MySQL people thought.
__________________
"I tried to go to Target but I missed" ~Mitch
VTJustinB is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old July 18th, 2003, 12:32 PM   #2 (permalink)
the one who was
Super #1
 
patrickb's Avatar
 
Joined in Jul 2003
Lives in Memphis
1,967 posts
Gave thanks: 0
Thanked 3 times
Im not really experienced in mySql, but I think that ENUMs are just a fancy string object. All you would really be doing is storing 6 more string fields in the database. Shouldn't hurt size much at all, and if you use some form of session tracking, you would only need to make that query for the user only one time for each session. Besides, I think the scripting that you do to manipulate the data will take more resources than doing the query..

Just my 1.5 cents worth.
__________________
Patrick

Warnings: The program(s) might crash unexpectedly or behave otherwise strangely. (But of course, so do many commercial programs on Windows.) --www.gimp.org
patrickb is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On