Php – Simple practical usable PHP logic for recurrence


I have submitted this previously but because someone down voted it and said it was already answered, no-one will answer it.

I know there are similar posts here:

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 and MySQL.

I do agree that this article is good, but it is so abstract that I cannot understand it.

I know there are other "Systems that have done this" but this is my own white whale, and I will figure it out at some point – I would just like some help along the way.

So, the question is: how do I build a recurring calendar using PHP and MySQL?

Best Solution

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.