How to update a database without the action from the customer?

Asked

Viewed 47 times

2

I am not very advanced in php, sql and everything, and I came up with the following doubt. Assuming today is the 10th and I want to pass the 12th a BD information is updated to 'sent' for example, if the user is open has no difficulty, but if no user enters the site until the 20th for example, how do I so that when that day comes, the server itself does this update?

  • Another option would be to use EVENT de prio mysql: https://dev.mysql.com/doc/refman/5.7/en/create-event.html

2 answers

3


What you will need is to create a script, for example in PHP, that runs the business rules you need, and schedule this task in a Cron Job system.

Cron Job is a type of Task Scheduler, where you will define the periodicity and which routine should be executed in this period.

So you can set up for example so that this PHP routine is called every 1 minute, thus making a processing independent of user accesses.

There are several Cron Job clients, including already embedded in Linux and Unix.

  • Intendi, with this I could execute any correct scrip! Applies in sending scheduled emails and various other things right? I’m going to go into Cron Job. Vlw

0

An option would be to store this date in a column of the database and when it is necessary to know whether or not it has passed two days just check with a clause WHERE, for example:

SELECT * FROM tabela WHERE NOW() > '$data';

Browser other questions tagged

You are not signed in. Login or sign up in order to post.