Hipny
Hipny

Reputation: 749

Bitwise Clarification

First and foremost, please let me clarify that I'm not a native english speaker, so please, excuse me for my faults.

I'm currently creating a PHP user system using a bitwise system permissions, and I will be stocking theses permissions into a MySQL database.

My question is the following. What type of row (int, varchar, ...) should I use to stock the permissions

My second question would be, how many permissions can be stocked? (32 bits have a limit of ~32 permissions (I think))

Thank you for you help!

Upvotes: 0

Views: 90

Answers (2)

Michael
Michael

Reputation: 12806

I would use one of the integer types. Which one depends on how many permissions you'll require.

TINYINT will allow for 8 permissions

SMALLINT will allow for 16 permissions

MEDIUMINT will allow for 24 permissions

INT will allow for 32 permissions

BIGINT will allow for 64 permissions

Upvotes: 1

juergen d
juergen d

Reputation: 204756

You could use the BIT(1) data type. Then you can use a bit column for every permission seperatly.

Upvotes: 0

Related Questions