xNeOx;10989598 wrote:I mean, I want my wall/feed to be displayed to people that someone is friends with?
if ($thisUser->friendCount() > 0)
$query = 'SELECT stuff FROM feed WHERE user_id = ' . $your_personal_id;
But perhaps you mean
I want my wall/feed to be displayed to people that I am friends with?
Or possibly
I want my wall/feed to be displayed to people that are friends of my friends?
You have to be careful how you express yourself, since the exact meaning of what you want has to be reflected in the code. Computers may dream of electric sheep, but they do not guess. And what you asked above is entirely different from my guesses of what you want.
If using a relational database, just check for the an existing entry in the user <-> user link table. Let's assume two tables: user(id, name, etc) and friend(user_id, friend_id) which both reference user(id).
For a particular $user, display his friends feeds.
$query = sprintf(
"SELECT some, stuff
FROM friend
INNER JOIN feed ON friend_id = feed.user_id
WHERE friend.user_id = %d",
$user->getId()
);
Should feeds of this user's friends' friends be included, you'd have to do something like
$query = sprintf(
"SELECT some, stuff
FROM friend f
INNER JOIN friend ff ON f.friend_id = ff.user_id
INNER JOIN feed ON ff.freind_id = feed.user_id
WHERE friend.user_id = %d",
$user->getId()
);