Array problem
#8

Quote:
Originally Posted by AmigaBlizzard
Посмотреть сообщение
It's bad practise to put multiple values into one field in a database.
It's a database, not a textfile (where you probably want to do this).

Just make each player-player friendship as a separate row in the table.
You only need 2 columns: PlayerID and FriendID.
You can even set both columns as primary key, so if you try to add the same friendship twice, the query will fail as it won't allow 2 rows with the exact same data (would be ridiculous as well).
And it's also alot easier to remove one player from his friendlist, you only need to delete the required row and it's done.
Not at all. It's bad practice to say "practice" wrong.

All you do is retrieve ONE field, and split it with sscanf or a custom split function.

But yeah, it's bad in this case since you'll have to retrieve the whole field then split it, just to check whether a player is friends with another player. It's just an example on how to create a list of friends without having the ability to "unfriend" someone.
Reply


Messages In This Thread
Array problem - by Marcuse - 19.01.2016, 17:56
Re: Array problem - by Crayder - 19.01.2016, 18:00
Re: Array problem - by Marcuse - 19.01.2016, 18:03
Re: Array problem - by AmigaBlizzard - 19.01.2016, 18:11
Re: Array problem - by Marcuse - 19.01.2016, 18:23
Re: Array problem - by SickAttack - 19.01.2016, 18:25
Re: Array problem - by AmigaBlizzard - 19.01.2016, 18:33
Re: Array problem - by SickAttack - 19.01.2016, 18:41
Re: Array problem - by AmigaBlizzard - 19.01.2016, 18:50

Forum Jump:


Users browsing this thread: 1 Guest(s)