/** This method is used to roll back user accounts the day before dawn*/ Public functionGetrollbackaccount ($startTime,$endTime){ //1. First check out the new user account for the day $sql _account= "Select DISTINCT ' AccountName ', ' mTime ' from ' t_log_register ' WHERE ' mTime ' >= ' {$startTime} ' and ' MTime ' <= ' {$endTime}‘"; $day _account= Fetchrowset ($sql _account); foreach($day _account as $key=$account) { $arr[] =$account[' AccountName ']; } //Statistics Roll Back user's time range limit within two months//$two _months_before_time = strtotime (Date ("Y-m-d", Strtotime ("2 Month" )); $now _end_time=$endTime-86400; //Bulk Query Limits $count _account=Count($arr); $base= 10; $group= Floor($count _account/$base); for($i= 0;$i<=$group;$i++) { Echo' <br>group: '.$i. "<br>"; $group _account= ' '; for($j= 0;$j<$base;$j++) { $key=$i*$base+$j; if($key<$count _account) { $group _account. = "'".$arr[$key] . "‘,"; } } $group _account=RTrim($group _account, ‘,‘); $sql _all_account= "Select DISTINCT ' AccountName ', ' agentid ', ' ServerID ', ' Platform ', ' mTime ' from ' t_log_register ' WHERE ' AccountName ' in ( {$group _account}) and ' MTime ' < ' {$now _end_time}‘ "; $all _account= Fetchrowset ($sql _all_account); if(!Empty($all _account)){ Break; } } $arr _account=Array(); foreach($all _account as $key=$before _account) { $arr _account[$key[' agentid '] =$before _account[' Agentid ']; $arr _account[$key[' serverid '] =$before _account[' ServerID ']; $arr _account[$key[' Platform '] =$before _account[' Platform ']; $arr _account[$key[' accountname '] =$before _account[' AccountName ']; $arr _account[$key[' mTime '] =$before _account[' MTime ']; } return $arr _account; }
How to encapsulate the number of in-limit queries in an SQL statement