示例#1
0
function syncQuery(Google_Service_Bigquery $bigquery, $projectId, $queryString, $timeout = 10000)
{
    $request = new Google_Service_Bigquery_QueryRequest();
    $request->setQuery($queryString);
    $request->setTimeoutMs($timeout);
    $response = $bigquery->jobs->query($projectId, $request);
    if (!$response->getJobComplete()) {
        return;
    }
    return $response->getRows() ? $response->getRows() : array();
}
示例#2
0
 function requestBigQuery($sql)
 {
     $query = new Google_Service_Bigquery_QueryRequest();
     $query->setQuery($sql);
     $query->setTimeoutMs(0);
     $response = $this->service->jobs->query($this->project_id, $query);
     $job_id = $response->getJobReference()->getJobId();
     $pageToken = null;
     do {
         $queryResults = $this->service->jobs->getQueryResults($this->project_id, $job_id);
         $queryResults->setPageToken($pageToken);
     } while (!$queryResults->getJobComplete());
     return $queryResults;
 }