PHP/MYSQL: Database Table For Email Notifications

这一生的挚爱 提交于 2021-02-20 02:52:49

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!