cron - tell php to create a new object at certain moments in time, Cronjobs? -


i’m trying create application current knowledge prevents me building it, hope can me!

scenario

i’m creating sort of dairy application. moment user presses start button object created, user can later edit filling in report.

now user allowed write 1 report every day, new object has added database @ 0:00 am, again can fill in.

question

how can tell php create new object @ moments in time?

i thinking of doing this:

  1. a page shows when no objects created far. new object created when button “start journey pressed”.
  2. a page adds object when time 0:00 (*using cronjobs?)
  3. a page displays created days , allows user edit them.

*so far solution i’ve found use cronjobs, i’m not familiar these. cronjobs right way go me , how can use them (i’m testing code on mamp)? or possible there solely php, , how?

all appreciated! lvroy

could possible (with restriction) generate object @ daily first use ? when user access panel, check there object (or not) day , if not create object ?

if okay you, :

first, add property user (in database/session) named "next_check" represent next time (date or timestamp) need check if object has been created.

at runtime, check if property lower current time, e.g :

if ($user['next_check'] <= time()) {    //create task } 

if need create task (condition true), create object , update "next_check" value time(). else, not anything.

notice solution lose history of objects since, if user not access app 10 days, there not objects created 10 days 1 when logs on app.

you of course improve generate object per day if user not access app iterating on conditions while "next_check" lower time().

while ($user['next_check'] <= time()) {    //create object    $user['next_check'] += 3600 * 24; } 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -