MilKMiracle
MilKMiracle

Reputation: 1

Automatic cleaning of the column in mysql

I am interested in this question, I need in my PHP application to limit the number of actions per day by one user. I want to do it as a counter with a record in a table. Let's say the number of button presses by a user has already reached the maximum number and the function will not be called again until the counter is zeroed. To do this, I need the counter column for ALL users to be cleared once a day. How can I do this?

Upvotes: 0

Views: 77

Answers (1)

Anup Patel
Anup Patel

Reputation: 74

Use cron jobs. cron jobs helps to run an particular code at a specific required time of the day as many times as required. and you can clear your database table from there itself.

set a cron expression to 0 0 * * *

These are some more valid formats for cron expressions for knowledge:

0 0 * * * = the top of every hour of every day.
*/10 * * * * = every ten seconds.
0 0 8-10 * * = 8, 9 and 10 o'clock of every day.
0 0 6,19 * * = 6:00 AM and 7:00 PM every day.
0 0/30 8-10 * * = 8:00, 8:30, 9:00, 9:30, 10:00 and 10:30 every day.
0 0 9-17 * MON-FRI = on the hour nine-to-five weekdays
0 0 25 12 * = every Christmas Day at midnight

The pattern to follow in cron expression is:

minute, hour, day, month, weekday

Upvotes: 2

Related Questions