Resetting a MySQL Field value without user execution

后端 未结 4 673
庸人自扰
庸人自扰 2021-01-28 14:10

I need to reset a MySQL Field value automatically at midnight. It is a specific column in a specific row in a table. I know how to do this in PHP but I do not know how to execut

4条回答
  •  北恋
    北恋 (楼主)
    2021-01-28 14:39

    You could write a job scheduler into your program that runs jobs in a cron-like way. It would require a user to interact with the system to trigger, but it might be good enough depending on your needs. This is much more complicated than just running a cronjob, and does not ensure prefect timing (since it wont run until a user hits a page).

    You'd probably need to add a table into you database that would list the job, the time you want them done, and a locking flag to avoid concurrent attempts to run the job. Each time your script runs, you'd check this table for overdue jobs and run them as needed.

提交回复
热议问题