dos8244 2016-02-03 04:52
浏览 131

php嵌套的do-while循环在第一次迭代后终止

I'm using nested do-while loop for accessing two json result, unfortunately the loop terminates after the first iteration where it returns outer-loop json result and not executing the inner-loop. Please find the function where am using nested do-while loop:

public function data_report($fromdate, $todate)
{
  $lp = new log_report();
  $mysqli = new mysqli("172.16.10.102", "aventador", "RND@ISO-3306", "eTrans");
  if ($mysqli->connect_errno) 
  {
      $response["success"] = 0;
  }
  if (!$mysqli->multi_query("call sp_Android_Online_Dashboard('$fromdate','$todate')")) 
  {
      $response["success"] = 0;
  }

  else {
    //1st Iteration 
  do {  
    if ($res = $mysqli->store_result()) 
    {
        $response["values"] = array();  
        while ($row = $res->fetch_assoc()) 
        {
            $i=1;
            $value = array();
            $value["location_name"] = $row["location_name"];
            $value["location_id"] = $row["location_id"];
            $value["Totfiles"] = $row["Totfiles"];
            $arr = explode(":", $row["file_minutes"], 2);
            $value["file_minutes"] = $arr[0];
            $value["Total_Lines"] = round($row["Total_Lines"], 0, PHP_ROUND_HALF_UP);

            array_push($response["values"], $value);    

            echo $i++;
        }   
    if (!$mysqli->multi_query("call sp_get_Android_Online_minutes_Chart('$fromdate','$todate')")) 
    {
            $response["success"] = 0;

    }

    //2nd Iteration
    do {
            if ($res = $mysqli->store_result()) 
            {
                $response["Chart_data"] = array();  

                while ($row = $res->fetch_assoc()) 
                {
                    $j=5;
                    $value = array();
                    $value["File_Day"] = $row["FileDay"];
                    $value["File_Minutes"] = $row["Tot_minutes"];
                    array_push($response["Chart_data"], $value);    

                }
                    $response["success"] = 1; 
                    echo json_encode($response, JSON_NUMERIC_CHECK);
                    $res->free();
                }

                echo $j++;

               } while($mysqli->more_results() && $mysqli->next_result());
           }

            echo json_encode($response, JSON_NUMERIC_CHECK);    

        } while($mysqli->more_results() && $mysqli->next_result()); 
    }
  }

Please help me out in solving this issue, thanks in advance!!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么