PHP循环有关问题

WBOY
Release: 2016-06-13 13:39:29
Original
860 people have browsed it

PHP循环问题
有一个数据表为 job 字段: id name content date

前提:
scrapy每时每刻会向数据库job表里写数据

问题:
每1分钟从从job表中读出最后一个数据,
与现在的时间做比对,如果现在的时间与date字段数据的时间相差30分钟,就跳出循环,否则就继续

用while循环做个死循环吗? 怎么做啊。谢谢



------解决方案--------------------
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);#这个函数不晓得管用不!
}
}
#前提:
#scrapy每时每刻会向数据库job表里写数据 
-----这个难道还会出现意外?蒙段时间写不进去数据?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template