|more useful options|
Re: Message Board Threading with DBI/MySQLby Henri Icarus (Beadle)
|on Jun 07, 2001 at 06:16 UTC||Need Help??|
The other thing you can do is you can store the thread id as a string of the id's of the message's replied to representing the actual thread hierarchy. This allows you to implement the same kind of thing that you see on this site where it's clear when looking at the threads which level their at.
So, for example, message 1 has two replies (messages 2 & 3), and there are also two repies to message 2 (messages 4 & 5). The thread ids for the messages are:
Message: 1 Thread ID: NULL
This lets you use SQL LIKE to pick out the exact level you want, ie:
SELECT ... WHERE thread_id LIKE "1_2%";
to get all the messages that thread with a message at a given reply level, etc..
You can also you regular expression searches for more complex searches. Of course such searches won't be indexable.
Also, using this method, if you sort by the thread id when you get back a list of messages then you can easily examine the thread id string with Perl regular expresions to figure out at which level of indentation to display it!