Welcome Guest, Not a member yet? Register   Sign In
Building a Read vs Unread Status for a Forum
#15

[eluser]vokic[/eluser]
[quote author="andrewtheandroid" date="1257522042"]Would this be ok for a group of around 500 users with light to casual forum usage in terms of performance?[/quote]

Well for that group I think you shouldn't even see any difference at all..
Just make additional field for thread in db like 'read' and when someone reads it add his user id into that field... When someone adds a reply, just completely delete that field and start again.. Smile And when you do the display just compare:

Code:
if(strstr($thread['read'], $user_id)) echo '<a href="thread_url"><b>Thread title</b></a>';
else echo '<a href="thread_url">Thread title</a>';

or something similar Smile

When someone goes to view the thread just add his user id if doesn't already exist:

Code:
if(!strstr($thread['read'], $user_id)) {
  $thread['read'] .= ' '.$user_id;
  $this->db->update('threads', $thread, 'id=thread_id';
}

That's actually all there is to it... But the troubles might start when you need to select only threads read by the user or threads subscribed..
There is that solution with LIKE : "SELECT * FROM threads WHERE thread_read LIKE $user_id" and we all know it will be slow for large records.. Maybe full text search would help at that situation... Then there are more solutions like: "SELECT * FROM threads WHERE LOCATE($user_id, $thread_read) > 0" or something similar which might be faster then LIKE etc.. It has flaws but hey, we are chatting about it Smile

I would prefer thread based solution over user based solution because it is easier to maintain... Operations are done only on that one field while on user approach every time you update a thread (read/noread/delete) you would have to update each user record..

Maybe for subscriptions you can go even with standard way of thread_id, user_id table cause it will be much less than read/noread records..


Messages In This Thread
Building a Read vs Unread Status for a Forum - by El Forum - 11-04-2009, 10:21 PM
Building a Read vs Unread Status for a Forum - by El Forum - 11-04-2009, 10:39 PM
Building a Read vs Unread Status for a Forum - by El Forum - 11-05-2009, 12:15 AM
Building a Read vs Unread Status for a Forum - by El Forum - 11-05-2009, 08:23 AM
Building a Read vs Unread Status for a Forum - by El Forum - 11-05-2009, 09:45 AM
Building a Read vs Unread Status for a Forum - by El Forum - 11-05-2009, 09:58 AM
Building a Read vs Unread Status for a Forum - by El Forum - 11-05-2009, 10:11 AM
Building a Read vs Unread Status for a Forum - by El Forum - 11-05-2009, 11:51 AM
Building a Read vs Unread Status for a Forum - by El Forum - 11-05-2009, 01:06 PM
Building a Read vs Unread Status for a Forum - by El Forum - 11-05-2009, 06:52 PM
Building a Read vs Unread Status for a Forum - by El Forum - 11-05-2009, 07:39 PM
Building a Read vs Unread Status for a Forum - by El Forum - 11-06-2009, 03:35 AM
Building a Read vs Unread Status for a Forum - by El Forum - 11-06-2009, 03:40 AM
Building a Read vs Unread Status for a Forum - by El Forum - 11-06-2009, 07:14 AM
Building a Read vs Unread Status for a Forum - by El Forum - 11-06-2009, 09:12 AM
Building a Read vs Unread Status for a Forum - by El Forum - 11-06-2009, 09:17 AM
Building a Read vs Unread Status for a Forum - by El Forum - 11-06-2009, 09:24 AM
Building a Read vs Unread Status for a Forum - by El Forum - 11-06-2009, 09:31 AM
Building a Read vs Unread Status for a Forum - by El Forum - 11-06-2009, 11:29 AM
Building a Read vs Unread Status for a Forum - by El Forum - 11-06-2009, 12:50 PM
Building a Read vs Unread Status for a Forum - by El Forum - 11-06-2009, 03:04 PM
Building a Read vs Unread Status for a Forum - by El Forum - 11-06-2009, 04:22 PM
Building a Read vs Unread Status for a Forum - by El Forum - 11-06-2009, 06:45 PM



Theme © iAndrew 2016 - Forum software by © MyBB