traq, I have an associaten table called "subscriptions". Probably my question is not clearly defined. An example.
I have a friend John and I belong to his group of friends with ID 123.
John posts something to the wall and allows to read this post to all friends who belong to the group 123.
The script will save to the MySQL table data in this way;
$result = mysql_query("INSERT INTO wall_posts
VALUES (NULL,'$poster','$post_text,'$friends_group_who_can_view_this_post')") or die('Error');
No problems so far and I can easy get all posts which I may read:
$result = mysql_query("SELECT poster, text, FROM wall_posts
WHERE friends_group_who_can_view_this_post='123'") or die('Error');
But now John posts another post and allows to read it to all friends who belong to groups 77, 123 and 321.
If I save it in this way:
$result = mysql_query("INSERT INTO wall_posts
VALUES (NULL,'$poster','$post_text,'77,123,321')") or die('Error');
it will cause selection problems because the column friends_group_who_can_view_this_post can not be INT and this will lead to full table scan.
The only solution that I see is to save all allowed groups as different posts:
[code=php][code=php]$result = mysql_query("INSERT INTO wall_posts VALUES (NULL,'$poster','$post_text,'777')") or die('Error');
$result = mysql_query("INSERT INTO wall_posts VALUES (NULL,'$poster','$post_text,'123')") or die('Error');
$result = mysql_query("INSERT INTO wall_posts VALUES (NULL,'$poster','$post_text,'321')") or die('Error');
[/code][/code]
But I don't know if it's the best solution. There are scripts like Phpfox that allow to set different and complicated permissions for each post (can read: friends, friends of friends, specific group of friends) but I don't want to spend 300 USD for a copy of script just to see 1 function.