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

How do thinkPHP forum posts get upvoted after new replies?

WBOY
Release: 2023-03-01 20:20:01
Original
1235 people have browsed it

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template