Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Mar 2009
    Location
    United Kingdom
    Posts
    161
    Thanks
    6
    Thanked 28 Times in 28 Posts

    Multiple records in one field

    Is there any way for multiple record to be stored into one field?

    Im trying to make a forum permission system where a user can view parts of the forum depending on their permissions. So is it possible to have a record with say multiple ids in, then php can identify each id? (e.g. a field with 1 3 6).

  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    You do not want to do that, it is bad database design. What you need to do is create a permissions table.

    You can have two columns, one is the user ID and the second is the forum ID they can access. Those two keys can then be a composite primary key.

    Then you can easily query if the user can access a certain forum easily as well.
    OracleGuy

  • #3
    Regular Coder
    Join Date
    Mar 2009
    Location
    United Kingdom
    Posts
    161
    Thanks
    6
    Thanked 28 Times in 28 Posts
    But what about multiple forums?

  • #4
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,306
    Thanks
    4
    Thanked 205 Times in 202 Posts
    Quote Originally Posted by Killermud View Post
    But what about multiple forums?
    You'd have a row in the second table for each forum a user has permissions for. That allows you to check the permissions for a forum with a single query.
    Dave .... HostMonster for all of your hosting needs

  • #5
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    You can have multiple rows with the same user ID and different forum IDs in your permissions table.

    Example:

    User ID | Forum ID
    -------------------
    1 | 1
    1 | 2
    2 | 1
    3 | 1
    3 | 2
    OracleGuy


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •