Reputation: 2530
I know this has been a question asked many times and I wish there was some solid answers out there, so i'm going to try and ask it and see if we can get a different response.
I realize there are tons of complexity's in dealing with recurring events. But is my understanding right if I were to do something like of this nature:
MySQL column (RRULE) When a user enters in an event ant says, "This repeats", now enter in this RRULE information Such as, (ie: FREQ=YEARLY;BYMONTH=3;BYDAY=2SU )
So use this method instead of INSERTING hundreds of events of the same thing, just create 1 table to store my repeating events and then add this RRULE column for the event, correct?
Question 2. How do you determine the maximum length of an event if stated, "Repeat this forever" (ie: a birthday).
Question 3. Is there a better way to do this, than what I am thinking?
If you could shed some light on what I am questioning, that would be greatly appreciated. I would like to write a class that handles all the information based on this setup but would like to know if I am on the right track or not.
Please and thank you!
Upvotes: 1
Views: 2328
Reputation: 8354
Yes, just enter it once. Calculate the first day for it to run, based off user input (what did they choose? yearly, monthly, etc) when you insert it, and put that in as the next run date. Also store their type choice. Then when you run the task at the specified time, you update the next run date/time based off the stored type choice. In addition you may want another field that indicates how many times to repeat; forever, 4 times etc. Decrement this accordingly when running the task.
Upvotes: 1