Restart PHP File
I have a php file run from command line, when it finishes a loop, it does a sql query, if there is anything new in the database that was added durring the time it was doing the previous sql query and loop, i would like to have the php file start over, otherwise exit, and close.
how would I do that?
You could use a DO..WHILE loop, with a pseudo condition at the end.
This would ensure that you perform at least one iteration and as many as needed until you explicitly leave the loop via "break".
$qry = mysql_query("SELECT `newitem` FROM `mytable`");
IF (mysql_num_rows($qry) == 0) :
} WHILE true;
Your could also re-execute the script using exec() for example.
But NightShifts idea is much better.
I think that the problem with exec() would be that, if this is a very active table with loads of new records added between queries, exec()'s would be calling themselves from within an exec() and the shell stack could end up breaking.
To go the way of exec() would probably require two scripts, one acting as the control instance and the other as the nested scripts.
I am giving your idea a try, it works.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)