I have a query I need to pitch even for once . With this method , but this method did use a lot of CPU and slows the server .
public function setRunningLevelsReadyToRun(){
$interval=5; //seconds
set_time_limit(0);
while(true) {
$now=time();
mysql_query("UPDATE `levels` SET status='running' WHERE 'NULL' not in (uid1,uid2,uid3,uid4) AND status = 'opened'") or die(mysql_error());
sleep($interval-(time()-$now));
}
}
I read this question but I want to run this method in separate thread.