1

我正在做一些小的事情,正在考虑制作一个像 facebook 这样的好的通知生成器。主要是我想要表格的外观。如何进行更新以及我应该拥有的所有必需品和注意事项谢谢

我有用户在他们上传图片时像个人资料一样发表评论

Facebook 的做法

4

2 回答 2

3

There's many ways to do it, one of which is to have a column in the table titled new_notification that will tell you if the notification is new(read by the user or not). So, for example, if a person likes another persons picture, in the table that column will have new_notification set to Y. When the user who's picture was liked logs into the website, you search for all rows where new_notification = Y do a count and show the number of notifications like facebook does. Once the user has seen the notifications or opened the notification bar, go through that table and set all the rows with new_notification = Y to 'N'.

于 2012-04-13T13:41:50.777 回答
2

是的,我同意@Interstellar_Coder,您可以将您的帖子页面信息存储在数据库表的一行中,并将您的类似信息存储在另一个表中。通过 ID 参考该人喜欢的图片。

表一(图片贴):

ID | Picture    | Comments   | who
1  | (pic data) | my picture | user.name_1

表2(喜欢):

row_ID | picture_ID | who
0      | 1          | user.name_2
1      | 1          | user.name_3

所以在这个例子中你有 1 张图片由 user.name_1 发布,那么这张图片已经被 user.name_2 和 user.name_3 点赞。我们知道这一点是因为likes表中的 picture_ID 字段。

你可以在你的数据库中查看谁喜欢ID=1的图片帖子,它会告诉你谁喜欢它,mysql代码示例:

select who from likes where picture_ID = 1;
于 2012-04-13T14:26:33.190 回答