How to encapsulate the number of in-limit queries in an SQL statement

Source: Internet
Author: User

    /** 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.