Not the answer you need?
Register and ask your own question!

continous task

LeinadLeinad EntrantInactive User Role Participant
Ok, I'm stuck again :/

I have 2 problems now (one lies withing mysql, and the other I just hope you know the answer :o )

a continuous task is the main one...

how do I create one?? and how do create an efficient one (mysql talkin')

I tried with this

while(1){ $starttime=time(); //your cron actions here //select all the ended builts $sql="SELECT * FROM twwbuilds WHERE endtime<$starttime"; $query=mysql_query($sql); $rows=mysql_num_rows($query); if($rows!=0) { $rs=mysql_fetch_assoc($query); do { $buildid=$rs["buildid"]; $sql="DELETE FROM twwbuilds WHERE buildid=$buildid";//much more code goes here, like updating the level of the building and stuff //besides building are not the only thing that need continuos checkin'...attacks and marketplace needs it too $query2=mysql_query($sql); }while($rs=mysql_fetch_assoc($query)); } sleep(5); }</pre>

I open the page and the task executes well as long as I keep the page open (YET here's one of my questions...it's efficient to do it this way??) when I close the page the task executes for like 1 minute then stops...how do I prevent this??

I REALLY need to continualy check if a building is over and the only way I have found is this continuos task.

or if you have a better way please tell me :/ my head-aches already ( :o
Sign In or Register to comment.

MySQL, InnoDB, MariaDB and MongoDB are trademarks of their respective owners.
Copyright ©2005 - 2020 Percona LLC. All rights reserved.