views:

765

answers:

2

Befor I ask this question, I have a favor to ask,

PLEASE don't down vote this question till it has some real answers.... PLEASE!

I have submitted this previously as the following question http://stackoverflow.com/questions/579892/php-calendar-recurrence-logic

but because someone down voted it and said it was already answered, noone will answer it

I know there are similar posts here... http://stackoverflow.com/questions/123793/design-question-how-would-you-design-a-recurring-event-system http://stackoverflow.com/questions/85699/whats-the-best-way-to-model-recurring-events-in-a-calendar-application

but they do not answer my request which is for a practical, simple and real-world example of logic for a recurring calendar setup, WITHOUT using another framework or tools/scripts other than straight PHP MYsQL

I do agree that this article http://martinfowler.com/apsupp/recurring.pdf is good, but it is so abstract that I cannot understand it...

if someone could PLEASE help me with this... I know there are other "Systems that have done this" but this is my own white whale -if you will- and I WILL figure it out at some point... I would just like some help along the way

and it was my understanding through the faq's that even if there are other posts it is still ok to ask a question and there are no questions that are too "noob"

thx

The question is: how do I build a recurring calendar using PHP and MySQL?

+1  A: 

You should strive to understand the Fowler article. It really does cover it.

The fact of the matter is, this is a hard problem. Editing logic "on the fly" is not something users really want to do. Rather, they want you as a programmer to have anticipated what they'll want to do and provided a rule for it--they don't want to have to figure out how to compute the second Wednesday of the month, for instance.

It sounds like your real problem lies in modeling the recurrence in MySQL. You could use Google's spec, which can be stored in a database and covered on Stack Overflow before. Fowler's piece also provides some good starting points in terms of well-defined classes that can be represented in an RDBMS.

It's a hard problem. And while SO wants you to succeed, we can only lead you to the stream. We can't force you to drink.

Jeremy DeGroot
I started as a ADD Visual designer, not coder so fowler's examples are way over my head... is there anything that can help me understand fowler?? an intermediary if you will??
Tim
Where do you feel like you fall short in your understanding? Are you not familiar with OO principles? Are the UML diagrams foreign to you? Or are there particular concepts that you don't fully grok? Asking about those specific things would help us help you.
Jeremy DeGroot
Well, i guess the real issue is, most problems I encounter or scripts I need to create involve taking something that is working and fiddeling with it till it breaks, then I fix it and modify it to my needs for that moment -- I guess that would mean I don't "Understand" any of it [;o)
Tim
example - public boolean isOccurring(String eventArg, Date aDate) { ScheduleElement eachSE;... I get the basic "Idea" of what the pieces are, but don't know what data or veriables go where and how to make it all work together
Tim
I would recommend editing your question to focus on those aspects of the Fowler paper, then. You'll get more help with specific questions than the somewhat vague and difficult one you posed.
Jeremy DeGroot
I understand and will try to post a new question - Are there any good resources for understanding the basic principles of PHP OOP??
Tim
This would be a good place to start. http://us2.php.net/manual/en/language.oop5.php. You might also pick up the Fourth Edition of "PHP and MySQL Web Development." I use it as a desk reference, and it covers all the basic concepts you'd want to build on.
Jeremy DeGroot
THANK You for your honest and helpful answer!
Tim
A: 

For a practical, real-world example of recurring calendar logic, look at your PDA or equivalent.

I got to build a calendar in an intranet application a few years ago and basically copied what my Palm had for recurring options. It made sense to people, so I judged it a success. But it didn't store real clean in the database. My code ended up with lots of careful checks that data was consistent along with various rules to correct things if something looked awry. It helped that we were actively using it as I was developing it. :-)

As far as storage went, the calendar entry involved a flag that indicated if it was part of a recurring series or not. If it wasn't, it was a non-recurring entry. If it was, then editing it had a couple of options, one of which was to break the series at this entry. Recurring entries were put into the database as discrete items; this was a type of denormalization that was done for performance reasons. Amongst other things, it meant that other code that wanted to check the calendar didn't have to worry about recurring items. We solved the "neverending" problem by always requiring an end-date to the series.

Actually setting up the recurring items involved some JavaScript in the UI to control the different settings. The entry in the DB had a combination of values to indicate the scope of the recurrence (e.g. daily, weekly, ...) the recurring step (e.g. 1 week, 2 weeks, ...) and any variation (weekly let you say "Monday, Wednesday, Thursday every week").

Finally, we had some logic that I never got to fully implement that handled timezones and daylight saving. This is difficult, because you have to allow the shift to apply selectively. That is, some calender items will stay in time local to the end-user, others are fixed to a location, and either may or may not shift with daylight saving. I left that company before I got a fix on that problem.

Lastly, I'm replying to this because I didn't see all the other questions. :-) But go read and understand that PDF.

staticsan