So I want to write something where people can set certain variables up to a certain time, at which time it will take the variables they set, and other data from a database, mash it together, and produce a "winner". A match engine would be the best way to describe it. However, I can't seem to find out a way to make it work the way I envision.
My first instinct was to find out some way to have a timed event, so at say 12AM every day, it grabs the data from the database, runs that engine on it, and then make the changes to the database necessary. However, I currently don't have access to cron, and php doesn't seem to spontaneously run its own code, and mysql only seems to have primitive timed events that wouldn't be able to perform the sort of operations I want.
So my second instinct was to do it by observation; nothing would happen until the first user logged in after that predetermined time, where it would run the engine on all the "games" that it needed to, because if no one looks at it, it doesn't need to be up to date. However, I'm worried that:
1) It might get run multiple times if people were to log in in quick succession after that time. How do I prevent that from happening, as in it gets run once and only once and that result is the one that gets recorded?
2) Something may happen so that it doesn't get run completely. I'm very new at PHP, but it stands to reason that if someone were to log on and then quit out very fast, the match engine would get stuck in midrun, and would be unable to either clear its past and return to the state it was before the aborted login, or finish the job without the user continuing to run the script. How do I ensure that it is run completely, from start to end, so that half results aren't spit out?
Hopefully someone is able to gleam something from that jumble of words and help me out, even if its pointing me on the right path. There may even be a completely different way of doing things that I'm unaware of, or some of my fears may be completely unnecessary.
Thanks in advance.