|
Posted by J.O. Aho on 08/18/06 21:05
Flaming Corncob wrote:
> I'm in the process of coding a forum. What I was looking for was
> something that keeps record of each folder/topic/subtopic/post, like an
> index number that is unique for each. When something is moved, edited or
> deleted it would make it easy to "refer" to a number and in the case for
> example it is deleted anything under that referencing that number is
> also deleted, and the number could be re-used. I thought indexes and
> such was the way to go, but I can't seem to make heads or tails what's
> going on.
You can have two columns, MessageID (int auto_increment) and ParentID (int),
for the first message the ParentID is 0, as it don't have a parent. All
replies to the first message in a thread will then have MessageID of the first
post as the ParentID.
When listing messages in a thread you sort them after MessageID, this will
give the flow in the same way as in phpBB (most popular forum used on the
net), if a message (reply) will be deleted you don't need to do anything extra
for make the thread to flow normally. If you delete a whole thread, it's quite
simple to delete all of them too.
Reusing ID-numbers can be a bad idea, specially as there are always someone
who does link to a thread from a web page, better in that case give a "error"
message than serve a thread that has nothing to do with the original thread.
//Aho
Navigation:
[Reply to this message]
|