Home > Article > Backend Development > How do thinkPHP forum posts get upvoted after new replies?
For example, I have two tables. One table, T1, is used to store topics. The other table, T2, is specifically used to store reply content. The id of T2 points to the id of T1. In this way, I can distinguish which topic the reply is from. All topics are by They are arranged in descending order by time, but generally forum posts will be pushed to the top if there are new replies. If you design the table like me, how can you make this post with new replies be pushed to the top? If this is still the case$t1- >order('time desc')->select()
;It definitely won't work. So how should I sort? I thought about using join or something before, but it didn't work. Is it unreasonable for me to design the table like this? Or what should I do? I use TP
For example, I have two tables. One table, T1, is used to store topics. The other table, T2, is specifically used to store reply content. The id of T2 points to the id of T1. In this way, I can distinguish which topic the reply is from. All topics are by They are arranged in descending order by time, but generally forum posts will be pushed to the top if there are new replies. If you design the table like me, how can you make this post with new replies be pushed to the top? If this is still the case$t1- >order('time desc')->select()
;It definitely won't work. So how should I sort? I thought about using join or something before, but it didn't work. Is it unreasonable for me to design the table like this? Or what should I do? I use TP
Add a field last_reply_time to the t1 table to represent the last reply time, and then update this field after inserting t2