Php:这个php脚本怎么需要太长时间才能响应?

时间:2018-05-31 15:12:41

标签: php mysql

我一直看到Waiting for Cache,至少需要30分钟 响应。 还有更好的方法吗?

这是链接: http://tapnapp.co/planning/phpScripts/getFullViewTasks.php?counter=1&sDateHour=1525154400&eDateHour=1527793200

这是代码:

<?php
if(isset($_GET['counter'])){
  require_once '../functions.php';

  $sDateHour = $_GET['sDateHour'];
  $eDateHour = $_GET['eDateHour'];

  $now = time() - 24*60*60;
  $fn= new Func;
  $fn->select('id_profile, groupe','profile',''," date_f_contract>='$now' AND groupe>0");

  $sel = new Func;
  $getHrName = new Func;

  while($row=mysqli_fetch_assoc($fn->select)){
    $pr_id=$row['id_profile'];


    $sel->select('*','counter',''," from_interval>='$sDateHour' AND to_interval<='$eDateHour' AND id_profile='$pr_id'");
    $nr= mysqli_num_rows($sel->select);



    if($nr>0){
      //here we have to do the total counter
      $totalCounter = 0;
      $from_interval=0;
      $to_interval = 0;
      $name ="";

      $tmp_id_profile = 0;
      $tmp_f_int =0;
      $tmp_to_int=0;

      while($r=mysqli_fetch_assoc($sel->select)){
        $frint = $r['from_interval'];
        $toint = $r['to_interval'];
        //$counter_ct = $r['counter'];

        $totalCounter+=$counter_ct;

        $getHrName->select('libelle AS lbl, COUNT(libelle) AS totalHr',"horraire",""," date_heure_deb>='$frint' AND date_heure_fin<='$toint' AND id_profile='$pr_id' GROUP BY libelle ORDER BY totalHr DESC LIMIT 1");
        $rr = mysqli_fetch_assoc($getHrName->select);
        $r['hrname']=$rr['lbl'];
        $name=$rr['lbl'];

        $r['counter']=$rr['totalHr'];

        /*
$from_interval=$frint;
        $to_interval = $toint;

        */


        $row['tasks'][]=$r;


      }
      /*
$r['counter']=$totalCounter;
      $r['from_interval']=$from_interval;
      $r['to_interval']=$to_interval;
      $r['hrname']=$name;*/


      //$row['tasks'][]=$r;
    }
    else{
      /*
      id_counter: "1",
      id_profile: "17",
      from_interval: "1519887600",
      to_interval: "1519934400",
      counter: "18"}
      */

      /*

      $fake['id_counter']=0;
      $fake['id_profile']=$pr_id;
      $fake['from_interval']=$sDateHour;
      $fake['to_interval']=$eDateHour;
      $fake['counter']=0;

      $row['tasks'][]=$fake;

      */



    }
      $res[]=$row;  
  }

  $temp['data']=$res;
  $fn->deconnect();
$sel->deconnect();


  echo json_encode($temp, JSON_PRETTY_PRINT);  
}

 ?>

如果有人能理解,这有什么问题? 那是因为mysql还是因为php?知道怎么解决吗? 谢谢!

0 个答案:

没有答案