问题
I want to notify users of changes on a site. Users are subscribed to different kinds of changes so I don't send all changes to all users.
Here's what I am thinking: at t=0
(i.e. an if statement that checks that some table is empty) I basically have an SQL query that fetches the appropriate changes and mails to the appropriate users. I then populate a user_changes table which essentially stores what changes have been mailed to what users. Mailing is done with the php mail
function
Then at t>0
, I run the SQL query again but this time with the condition that changes+user
are not in the user_changes table. The main issue i see with this is that the user_changes
table could get large very quickly. Is this a problem? I am trying to avoid hacks that use dates to filter stuff, since I want new users to be able to receive old changes that are relevant to them.
Appreciate suggestions.
回答1:
How about having one entry per user, and a record of the last sequence number of updates? when you send the email updates, update the record with the latest and greatest. Your table should be sized with your user base, then.
来源:https://stackoverflow.com/questions/6726220/php-mysql-database-table-for-email-notifications