Announcement

Collapse
No announcement yet.

Larger Bitfields

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Larger Bitfields

    Is there an accepted way (or data type) to allow for more than 32 (2^31) values in a bitfield variable?

    I am writing a CMS for one of my websites and was going to use a bitfield for category access control (on the admin side, e.g. who can post to what category) but I'd like it to be able to scale up as more categories are added. Obviously a limit of 32 categories is undesirable.

    Possible to do with bitfields, or bad idea? Thanks!
    Editor, Xtreme RC Cars Magazine
    Owner, R/C Tech

  • #2
    You can make the bitfield a LARGEINT and also make it Unsigned.

    That should let you have
    2^64
    Scott MacVicar

    My Blog | Twitter

    Comment


    • #3
      Sounds like a weird setup, to me... If you add multiple categories, shouldn't they go into new rows in a database table, instead of stacked in one row as a bitfield? o_O

      Comment


      • #4
        Originally posted by KuraFire
        Sounds like a weird setup, to me... If you add multiple categories, shouldn't they go into new rows in a database table, instead of stacked in one row as a bitfield? o_O
        Some people would agree with you about columns and some wouldn't.

        As for the size, if you have a 32 bit system, PHP's INT only functions up to 32 bits. It casts to a float for anything over that and you can bit-switch a float.

        Comment


        • #5
          Originally posted by KuraFire
          Sounds like a weird setup, to me... If you add multiple categories, shouldn't they go into new rows in a database table, instead of stacked in one row as a bitfield? o_O
          I have an application that will require about 40 different boolean settings, all control variables, on or off -- 1 or 0. Each entry into this table will require its own set of settings, so to me, it seems that bitfields are the best way to accomplish this, since I can then have one or two integer fields that will contain all of my settings.

          If you can think of a better way to do it, then by all means enlighten me...

          Thanks for the information, guys.
          Editor, Xtreme RC Cars Magazine
          Owner, R/C Tech

          Comment

          widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
          Working...
          X