Jump to content

allowing users to block each other


Ska

Recommended Posts

I am writing a simple private message system, but I am a bit stumped about this part. The message part is easy as pie.

 

Users are based on their IDs, so say we have 5 users - 1 2 3 4 and 5.

 

How would I set up a table for a banlist? The only way I could think of doing it (and there must be a simplier way) is having a table that is as wide as it is long full of true or false (yes/no).

 

... 1 . 2 . 3 . 4 . 5

1. F . T . F . F . T

2. F . F . F . F . F

3. T . T . F . F . T

4. F . F . F . F . F

5. F . F . T . F . F

 

So 1 has blocked 2.

2 has blocked no one.

3 has blocked 1 2 and 5.

3 has no blocked anyone.

5 has blocked 3.

 

But this could very easily become millions/trillions of entries. Is there another way to do this?

 

Thanks in advance :)

Link to comment
https://forums.phpfreaks.com/topic/202580-allowing-users-to-block-each-other/
Share on other sites

How about table like this?

 

table user_bans

user_id, banned_user_id

----------------

1,2

1,5

3,1

3,2

3,5

5,3

 

Continuing on this, I would extend it's functionality a little further and define the relationship status between 2 users (friends, lovers, haters, ..). Although you may not need the functionality now, it may well in the future.

Yeah, thanks for that :) I actually thought about that just before I fell asleep last night, having a ban table with;

 

blockid, blockerid, blockedid, date, dateunblocked, active, reason

 

This way, people can remove the ban (ie - active no) but it stays in the table so that mods can view the history.

 

Don't know why my brain went into a spasm and couldn't think of this yesterday, too much coding, not enough sex.  8)

 

Thanks again :)

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.