php代码
Last updated
Was this helpful?
Last updated
Was this helpful?
<?php
require 'vendor/autoload.php';
use Google\Cloud\BigQuery\BigQueryClient;
$bigQuery = new BigQueryClient(['keyFilePath' => './keybig.json']);
$maxResults = 1000;
$startIndex = 0;
$options = [
'maxResults' => $maxResults,
'startIndex' => $startIndex
];
$dataset = $bigQuery->dataset('austin_311');
$table = $dataset->table('311_request');
$numRows = 0;
foreach ($table->rows($options) as $row) {
print('---');
foreach ($row as $column => $value) {
printf('%s: %s' . PHP_EOL, $column, $value);
}
$numRows++;
}
<?php
require 'vendor/autoload.php';
use Google\Cloud\BigQuery\BigQueryClient;
$bigQuery = new BigQueryClient(['keyFilePath' => './keybig.json']);
$maxResults = 1000;
$startIndex = 0;
$queryJobConfig = $bigQuery->query(
"SELECT * FROM `bigquery-public-data.austin_311.311_request` LIMIT 120000"
);
$queryResults = $bigQuery->runQuery($queryJobConfig);
/* foreach ($queryResults as $row) {
print_r($row);
file_put_contents("/tmp/test/bigquery", $row['unique_key'].PHP_EOL,FILE_APPEND);
}
die; */
$options = [
'maxResults' => $maxResults,
'startIndex' => $startIndex
];
$numRows = 0;
foreach ($queryResults->rows($options) as $row) {
file_put_contents("/tmp/test/bigquery", $row['unique_key'].PHP_EOL,FILE_APPEND);
$numRows++;
echo '---'.$numRows.PHP_EOL;
}