0

Google BigQuery의 테이블에서 추출한 행에서 행을 읽으려고하면 배열의 첫 번째 행만 읽습니다.Google BigQuery 배열로 행을 읽는 중

나는 그것을 다른 코드에 같은 방식으로 일을하고이 모든 행을 읽는되지 않는 이유를 모르는

<?php 
    function top10($chart){ 
     $client = new Google_Client(); 
     $client->useApplicationDefaultCredentials(); 
     $client->addScope(Google_Service_Bigquery::BIGQUERY); 
     $bigquery = new Google_Service_Bigquery($client); 
     $projectId = 'projectID'; 

     $request = new Google_Service_Bigquery_QueryRequest(); 

     $query = "SELECT First_Name, Last_Name, G FROM [" . $chart. "] ORDER BY G DESC LIMIT 10"; 

     $request->setQuery($query); 

     $response = $bigquery->jobs->query($projectId, $request); 
     $rows = $response->getRows(); 

     $ii = 0; 
     $i = 0; 
     foreach ($rows as $row) 
     { 
      foreach ($row['f'] as $field) 
      { 
       $Info[$i][$ii] = $field['v']; 
       $ii++; 
      } 
      $i++; 
     } 
    } 
?> 

답변

1

이 같은 것을 사용해야합니다.

$rows = $queryResults->rows(); 
     foreach ($rows as $row) { 
      printf('--- Row %s ---' . PHP_EOL, ++$i); 
      foreach ($row as $column => $value) { 
       printf('%s: %s' . PHP_EOL, $column, $value); 
      } 
     } 

전체 예제 here

관련 문제