From a query about creating events in Mysql
An example you can see here, and try to fit into your problem
How to create a daily event in Mysql 5.6?
(A question asked here on the website)
Edited:
To create an event
CREATE
[DEFINER = { user | CURRENT_USER }]
EVENT
[IF NOT EXISTS]
event_name
ON SCHEDULE schedule
[ON COMPLETION [NOT] PRESERVE]
[ENABLE | DISABLE | DISABLE ON SLAVE]
[COMMENT 'comment']
DO event_body;
schedule:
AT timestamp [+ INTERVAL interval] ...
| EVERY interval
[STARTS timestamp [+ INTERVAL interval] ...]
[ENDS timestamp [+ INTERVAL interval] ...]
interval:
quantity {YEAR | QUARTER | MONTH | DAY | HOUR | MINUTE |
WEEK | SECOND | YEAR_MONTH | DAY_HOUR | DAY_MINUTE |
DAY_SECOND | HOUR_MINUTE | HOUR_SECOND | MINUTE_SECOND}
You could create a daily event that will validate whether the date of the day is equal to the date datafinal
and if you change your status to 2
Example
An example of your case would be +/- that
CREATE DEFINER=`root`@`localhost` EVENT `atualiza_clientes_vips`
ON SCHEDULE
EVERY 1 DAY STARTS '2018-05-03 12:00:00'
ON COMPLETION PRESERVE
ENABLE
COMMENT ''
DO BEGIN
update SUATABELA set status = 2
where datafinal >= CURRENT_DATE()
END
As he starts today at 12hr, every day at 12hr he will run again
cool, I’ll read it, thanks
– Leandro Marzullo
While this link may answer the question, it is best to include the essential parts of the answer here and provide the link for reference. Replies per link only can be invalidated if the page with the link is changed. - Of Revision
– Leandro Angelo
@Leandroangelo I will take more care and follow your recommendation
– Matheus Ribeiro
then I would put this being called by a function in PHP, when the client makes the payment, this?
– Leandro Marzullo
The event is created in the database itself and the database takes care of running it daily (if you create the daily event), so you wouldn’t need to call it in php.
– Matheus Ribeiro
Please check the answer again and check the Example
– Matheus Ribeiro
Thank you! I tested and gave this error: #1064 - You have a syntax error in your SQL next to 'END' on line 10
– Leandro Marzullo
if you just copied and pasted my example, this error is that famous ERROR - Missing only the ; at the end of the update
– Matheus Ribeiro