У меня есть 3 таблицы в моей базе данных, tbl_events, tbl_exceptions, tbl_archived_events
tbl_events хранит список событий, содержит следующие поля
**eventID** => int(4)Key, AutoIncrement
eventREF => VARCHAR (4) ( will remain the same for each version of the event and will be used to check for an exception)
eventName => VARCHAR (30) (Name of the event)
eventType => int(4) will determine the type of event it is
eventLocation => VARCHAR (30) hold the event location data
eventDate => DATETIME hold the date of the event
eventStart => DATETIME hold the start time of the event
eventEnd => DATETIME hold the end time of the event
isReoccuring => int(2) Default to 1 which means it is reoccurring
frequency => VARCHAR (10) will be either Daily/Weekly/Monthly/Yearly
eventLink => VARCHAR (30) will contain a link to the event page if there is one
eventValid => int(2) Will be set to 1 if the event is on and 0 if there is an exception
tbl_exceptions хранит набор событий и даты их проведения. Могут быть определенные моменты, когда повторяющееся событие может не проводиться. Эта таблица будет содержать следующую информацию поля
**exceptionID** KeyField, AutoIncrement => int(4)
eventREF => VARCHAR (4) Holds the event ref number
exceptionDate => DATETIME , Hold the date of the exception
tbl_archive_events будет хранить прошлые события, которые истекли. эта таблица будет хранить те же данные, что и таблица tbl_events, но только для прошлых событий
**eventID** => int(4)Key, AutoIncrement
eventREF => VARCHAR (4) ( will remain the same for each version of the event and will be used to check for an exception)
eventName => VARCHAR (30) (Name of the event)
eventType => int(4) will determine the type of event it is
eventLocation => VARCHAR (30) hold the event location data
eventDate => DATETIME hold the date of the event
eventStart => DATETIME hold the start time of the event
eventEnd => DATETIME hold the end time of the event
isReoccuring => int(2) Default to 1 which means it is reoccurring
frequency => VARCHAR (10) will be either Daily/Weekly/Monthly/Yearly
eventLink => VARCHAR (30) will contain a link to the event page if there is one
eventValid => int(2) Will be set to 1 if the event is on and 0 if there is an exception[/CODE]
Поэтому, когда событие истекло, я бы хотел, чтобы mysql сделал следующее:
у меня есть это до сих пор
DELIMITER $$
CREATE
EVENT `new_event`
ON SCHEDULE EVERY 1 DAY STARTS '2016-07-24 03:00:00'
DO BEGIN
-- create new event
SELECT eventID, eventREF, eventTitle, eventLocation, eventDate, eventStart, eventEnd, isReoccuring, frequency, eventType, eventLink, eventValid
FROM tbl_events
WHERE eventDate < now()
--- for each event found create a new event
INSERT INTO tbl_events (eventID, eventREF, eventTitle, eventLocation, eventDate, eventStart, eventEnd, isReoccuring, frequency, eventType, eventLink, eventValid)-- copy expired events to tbl_archived_events
INSERT INTO tbh_archived_events (eventID, eventREF, eventTitle, eventLocation, eventDate, eventStart, eventEnd, isReoccuring, frequency, eventType, eventLink, eventValid)
SELECT eventID, eventREF, eventTitle, eventLocation, eventDate, eventStart, eventEnd, isReoccuring, frequency, eventType, eventLink, eventValid
FROM tbl_events
WHERE eventDate < now();
-- delete expired events from tbl_events
DELETE FROM tbl_events WHERE eventDate < now();
END */$$[/PHP]
Очевидно, что вышеупомянутое не является правильным, и я не совсем уверен, что я делаю, был бы признателен за помощь, пожалуйста
Спасибо
Люк
Вы можете использовать планировщик mysql для запуска каждые 5 секунд или 1 раз в день.
http://dev.mysql.com/doc/refman/5.1/en/create-event.html
Никто не использует эту вещь
СОЗДАТЬ СОБЫТИЕ
НА ГРАФИКЕ КАЖДОЕ 1 (ВТОРОЙ, ДЕНЬ)
ДЕЛАТЬ
ПОЗВОНИТЕ СВОЮ СТРОРЕПРОЦЕДУРУ ();
Создайте свой SP отдельно
Других решений пока нет …