问题描述
我有一个网站,允许用户下载PDF文件,我每天为每个用户限制10个文件的下载,并将数字存储在MySQL数据库中.一切正常!
I have a website that let users download PDF files,I made a download limit 10 files per day for each user and I stored the numbers inside MySQL database. everything works great!
问题是:限制将被永久设置,我希望将其每24h重置为0.是否有任何phpmyadmin命令或每隔24小时自动将该列重置为0或通过其他方式重置的内容!
The problem is: The limit will be set forever, I want it to reset to 0 each 24h.Is there any phpmyadmin command or something to reset that column each 24h to 0 automatically or any other way!
推荐答案
似乎您已经将下载计数存储在各种日志表中.
It looks like you are already storing the download counts in a log table of sorts.
为使这些计数过期,我建议使用MySQL固有的事件调度程序.您可能需要在服务器参数中启用它.
For expiring those counts, I suggest using the event scheduler native to MySQL. You may need to enable it in your server parameters.
语法看起来像这样:
CREATE EVENT myevent
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 DAY
DO
UPDATE count_db.count_table SET count_column = 0;
这篇关于如何每24小时将mysql列重置为0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!