English 中文(简体)
网址的新评论通知执行情况
原标题:new comments notification implementation for a web site
  • 时间:2011-03-16 15:56:31
  •  标签:
  • php
  • mysql

我有一个网站,让人们能够担任职务并发表评论。 我想提出一个新的评论通知制度,这样当他的一个用户记录能够看到对其职位的新评论数目时。

我的想法是增加一个读表,其中我将储存用户_id和评论_id(用户_id读评论)。 但是,如果表率会扩大,这可能会造成一些业绩问题。

如何以最佳方式执行?

最佳回答

实现这一目的的一个途径是节省一个既定的员额和评论日期,以及用户的“最后访问”日期(或“用户点击“我的新职位”链接的最后时间)。

然后,你只需要获得比用户表中更新的日期的所有职位和评论。

问题回答

如何仅仅储存用户和评论ID供不阅读的评论? 当用户读到评论时,你可以删除表上这一行文。

是否最好在通知表中储存员额时间,然后研究用户的最后活动(储存用户表的价值)。 然后,你可以简单地问:

$lastActivityTime = User->GetLastActivity();
$result = mysql_num_rows(mysql_query("SELECT COUNT(`id`) FROM `notifications` WHERE `postTime` >  $lastActivityTime "));

亲爱!

你们可以选择与我的SQL不同的存储方式(Like :MongoDB)。

或者,你可以为通知用户提供公共/次级实施。 (在使用公共代用品的情况下,你打算储存数据。) 通知





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签