Help - Search - Members - Calendar
Full Version: Another question...
Invision Power Services > Community Forums > Community Web Design and Coding
Kenny Pollock
Sorry to keep asking questions... I'm just looking for answers.

Friends table
User_id, friend_id

If user ID 2 adds friend 3, I want friend 3 to be asked if they want to add friend 2.

I can't think of a simple solution to this...although I'm sure the solution is simple.

Thanks again guys!
Starnox
Just add an extra column 'validated', or an non-validated table and a validated table. Then if user ID = {your_id} and validated = 0 then ask the question. If they accept change it to 1 or something, if they don't delete it.
Brendon Koz
Hmmm, that works. I just realized that what I was thinking, if user_id 2 said "no", it would keep asking. tongue.gif
Kenny Pollock
Wouldn't that just be a waste of space in the database?

I mean, I have a feeling it can be done with a query or two, I just don't know the right query.

malikyte: If a user said no, it would be deleted from the database, therefore not asked again.
princetontiger
Have a separate table for validated... sort of like a payment. And you can keep if you want for user history or whatnot. So, if there is a new order made to add another user to a user's buddy list, it will be marked as pending and await approval. Keep in mind, you'll be using a join.
Kenny Pollock
Is that really the most effecient thing though?

The way I keep looking at my situation is, have a query like SELECT * FROM friends WHERE friend_id = $logged_in_guys_id AND WHERE user_id does not have a friend with the id that added you.
princetontiger
Not sure if it's the most efficient, but it can be the most efficient if you implement it properly. I believe it is, though. You could see how the buddy list works on some other forums and whether or not they use their own table... I don't normally look at other code, though - so I can't tell you.
Brendon Koz
Kenny, the reason I said what I said was because I was basically thinking along the same lines as you, except...how would you tell if friend #2 denied the ability to add #1 to their list? You couldn't..

...you could add a field to the lookup table, something like "reciprocal_view", meaning the other person saw they were added. Set it to 0 (or null, or "no/n" for enum) and upon viewing it (and/or deciding on a path), it'll be changed to something else so they won't see the message again, and they can either add that person or not.

That's a bit wordy and oddly stated, if you want me to explain it a bit clearer, lemme know.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.