A
A
AR2017-10-06 23:53:41
MySQL
AR, 2017-10-06 23:53:41

How to make the status of unread comments?

Good afternoon.
There is a project in which there are users and there are comments to some entity.
How to properly indicate unread messages? Those. for one user, the message "A" may be read, and for another, the same message "A" may be unread.
Nothing but a table for unread comments pirhod (id_comment, id_user) Yii2
project.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
A
Andrey Burov, 2017-10-07
@BuriK666

record the date of the last visit to the topic, and consider all comments that were after the date of the last visit unread.

S
Sergey, 2017-10-07
@gangstarcj

Attendance statistics are not kept?
You can keep statistics on which pages the user was on at what time.
Accordingly, correlate the time of visit and the time of publication of comments.

U
Uno, 2017-10-07
@Noizefan

By date 100%.
This is economical in terms of disk space.

B
bkosun, 2017-10-07
@bkosun

Nothing except the table for unread comments feasts
(id_comment, id_user)

Suppose there are 100500 users registered in the system, after adding a new comment, will you need to add information about the new unread comment to everyone? What if the comment is edited? What to do with new users?
Properly store views, not "unread comments":
comments
id, user_id, text, ...

comment_views
id, comment_id, user_id, ...

M
maiskiykot, 2017-10-08
@maiskiykot

And why does everyone always try to write everything to the database? There are cookies, and in most cases it is enough to write the client in cookies and that's it. Why load the base?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question