[wp-hackers] select all users with role X
Robert Deaton
false.hopes at gmail.com
Tue Dec 27 05:15:19 GMT 2005
On 12/26/05, Roy Schestowitz <r at schestowitz.com> wrote:
> _____/ On Tue 27 Dec 2005 03:22:20 GMT, [Aaron Brazell] wrote : \_____
> As Robert pointed out, hanging bits off the core is rarely the
> desirable option.
> I don't know particular database systems, but the correct thing is to do a
> table join of all users and then apply a mask. In this case, it can even be
> bitwise. I don't know how/if you can do this in MySQL. Here is a very
> simplified example:
>
>
> |user-id|role|email|
> |0000000|0011|10000|
> |0000001|0011|01011|
> |0000010|0010|01101|
> |0000011|0100|01010|
> |0000100|0011|01000|
> |0000101|0010|01111|
>
> Assuming administrator corresponds to level 8, apply XOR mask to role:
>
> 0100
>
> If 0, you found an administrator, so get fetch from the table.
>
As this was already discussed on IRC, this is far from the right
choice, because of plugins. Plugins should be able to add their own
roles, which may work fine, we just append another bit. However, for a
typical 32-bit integer, we're limited to 8 roles. Besides that,
plugins that are deactivated then leave huge amounts of cruft behind
without complicated code to remove their options. I don't see any
reason why a typical table that we can use in JOINs is out of the
question.
> Roy
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
--
--Robert Deaton
http://somethingunpredictable.com
More information about the wp-hackers
mailing list