Home  >  Article  >  Backend Development  >  How do thinkPHP forum posts get upvoted after new replies?

How do thinkPHP forum posts get upvoted after new replies?

WBOY
WBOYOriginal
2016-12-01 00:26:041199browse

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
How do thinkPHP forum posts get upvoted after new replies?

Reply content:

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
How do thinkPHP forum posts get upvoted after new replies?

Add a field last_reply_time to the t1 table to represent the last reply time, and then update this field after inserting t2

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn