I have a table that needs to be updated every 5 days by members. The event scheduler is to set any stale row to zero, if the row's last update is older than 5 days. My development environment is:
Windows 7, 32bit.
MySQL 5.5.39
PHP 5.4.45
My first query was:
$query = 'CREATE EVENT event_name
ON SCHEDULE EVERY 5 HOUR
ON COMPLETION PRESERVE ENABLE
DO
UPDATE database_name.table_name SET table_column_name = 0 WHERE (CURRENT_TIMESTAMP - last_update_date) > 5 DAY'
I ran the script in PHP but the browser simply stopped. Displaying 'Server not found'.
Then I tested it in phpMyAdmin. This time I get:
#1064 - You have an error in your SQL syntax. Check the mysql manual that corresponds to your mysql server version for the right syntax to use near 'DAY'.
I checked MySQL Reference Manual (for version 5.6, though). My query seems correct, unless I'm missing something. So I changed the query to:
CREATE EVENT event_name
STARTS '2015-11-01 00:00:00'
ENDS '2030-11-01 00:00:00'
ON SCHEDULE EVERY 5 HOUR
ON COMPLETION PRESERVE ENABLE
DO
UPDATE database_name.table_name SET table_column_name = 0 WHERE (NOW() - last_update_date) > 5 DAY
Still got the same results.
In reference to a related topic ((How to schedule a stored procedure in MySQL)), there's no event_scheduler
in my php info.
Please help.