문제

I am modifying my PHP network's code to have "user roles" like wordpress here is my plan so far

0 = registred non email verified user
1 = registed and verified email
2 = moderator
3-9 = nothing yet
10= admin

In my PHP code I will use an array like this that will set what a role number does.

$user_role['10']

I was thinking of storing which value a user has in my mysql DB, would this be the best way to store the 10 different role options as an enum or is there a better way or faster way? I read that enum is not the fastest sometimes.

enum('0','1','2','3','4','5','6','7','8','9','10')
도움이 되었습니까?

해결책

I guess INT or TINYINT is enough to store user level (role). Also you may consider multiplting the numbers by 10, so you'll have a space to add more levels in future.

다른 팁

Use bitmasks for permissions / user levels.

See example.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top