For PHP loop problems, there is a data table with the job field: idnamecontentdate. premise: scrapy writes data to the database job table every moment. problem: the last data is read from the job table every minute, compared with the current time, if the current time is 30 minutes different from the date field data time, the loop will jump out. otherwise, will the while loop be used to create an endless loop? How to do this. Thank you ------ solution ---- PHP loop problem
There is a data table named job field: id name content date
Prerequisites:
Scrapy writes data to the database job table every moment.
Problem:
Read the last data from the job table every minute,
Compare with the current time. if the difference between the current time and the date field data time is 30 minutes, it will jump out of the loop; otherwise, it will continue.
Do I use a while loop to create an endless loop? How to do this. Thank you.
------ Solution --------------------
While (1 ){
$ SQL = "select * from job order by id desc limit 1 ";
$ Rs = mysql_query ($ SQL );
$ Date = mysql_fetch_array ($ rs );
$ Time_shijiancha = time ()-$ date ['Date'];
If ($ time_shijiancha> 30 ){
Break;
} Else {
Sellp (1); # I don't know if this function works!
}
}
# Prerequisites:
# Scrapy writes data to the database job table every moment
----- Is this still unexpected? Why can't I write data for a certain period of time?