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

関連する問題