BigQuery/src/BigQueryClient.php
public function runQuery(JobConfigurationInterface $query, array $options = [])
    {
        $queryResultsOptions = $this->pluckArray([
            'maxResults',
            'startIndex',
            'timeoutMs',
            'maxRetries'
        ], $options);
        $queryResultsOptions['initialTimeoutMs'] = 10000;

        $queryResults = $this->startQuery(
            $query,
            $options
        )->queryResults($queryResultsOptions + $options);
        $queryResults->waitUntilComplete();
        return $queryResults;
    }
public function runQuery(JobConfigurationInterface $query, array $options = [])
    {
        $queryResultsOptions = $this->pluckArray([
            'maxResults',
            'startIndex',
            'timeoutMs',
            'maxRetries'
        ], $options);
        $queryResultsOptions['initialTimeoutMs'] = 10000;

        $queryResults = $this->startQuery(
            $query,
            $options
        )->queryResults($queryResultsOptions + $options);
        $queryResults->waitUntilComplete();
        return $queryResults;
    }
public function runQuery ( JobConfigurationInterface $ query , array $ options = [ ] ) { $ queryResultsOptions = $ this -> pluckArray ( [ 'maxResults' , 'startIndex' , 'timeoutMs' , 'maxRetries' ] , $ options ) ; $ queryResultsOptions [ 'initialTimeoutMs' ] = 10000 ; $ queryResults = $ this -> startQuery ( $ query , $ options ) -> queryResults ( $ queryResultsOptions + $ options ) ; $ queryResults -> waitUntilComplete ( ) ; return $ queryResults ; }
Runs a BigQuery SQL query in a synchronous fashion.

Unless `$options.maxRetries` is specified, this method will block until
the query completes, at which time the result set will be returned.

Queries constructed using
[standard SQL](https://cloud.google.com/bigquery/docs/reference/standard-sql/)
can take advantage of parameterization.

Refer to the table below for a guide on how parameter types are mapped to
their BigQuery equivalents.

| **PHP Type**                               | **BigQuery Data Type**               |
|--------------------------------------------|--------------------------------------|
| `\DateTimeInterface`                       | `DATETIME`                           |
| {@see Google\Cloud\BigQuery\Bytes}         | `BYTES`                              |
| {@see Google\Cloud\BigQuery\Date}          | `DATE`                               |
| {@see Google\Cloud\Core\Int64}             | `INT64`                              |
| {@see Google\Cloud\BigQuery\Time}          | `TIME`                               |
| {@see Google\Cloud\BigQuery\Timestamp}     | `TIMESTAMP`                          |
| Associative Array                          | `STRUCT`                             |
| Non-Associative Array                      | `ARRAY`                              |
| `float`                                    | `FLOAT64`                            |
| `int`                                      | `INT64`                              |
| `string`                                   | `STRING`                             |
| `resource`                                 | `BYTES`                              |
| `bool`                                     | `BOOL`                               |
| `object` (Outside types specified above)   | **ERROR** `InvalidArgumentException` |

Example:
```
$queryJobConfig = $bigQuery->query(
'SELECT commit FROM `bigquery-public-data.github_repos.commits` LIMIT 100'
);
$queryResults = $bigQuery->runQuery($queryJobConfig);

foreach ($queryResults as $row) {
echo $row['commit'];
}
```

```
// Construct a query utilizing named parameters.
$query = 'SELECT commit FROM `bigquery-public-data.github_repos.commits`' .
'WHERE author.date < @date AND message = @message LIMIT 100';
$queryJobConfig = $bigQuery->query($query)
->parameters([
'date' => $bigQuery->timestamp(new \DateTime('1980-01-01 12:15:00Z')),
'message' => 'A commit message.'
]);
$queryResults = $bigQuery->runQuery($queryJobConfig);

foreach ($queryResults as $row) {
echo $row['commit'];
}
```

```
// Construct a query utilizing positional parameters.
$query = 'SELECT commit FROM `bigquery-public-data.github_repos.commits` WHERE message = ? LIMIT 100';
$queryJobConfig = $bigQuery->query($query)
->parameters(['A commit message.']);
$queryResults = $bigQuery->runQuery($queryJobConfig);

foreach ($queryResults as $row) {
echo $row['commit'];
}
```

@see https://cloud.google.com/bigquery/docs/reference/v2/jobs/query Query API documentation.

@param QueryJobConfiguration $query A BigQuery SQL query configuration.
@param array $options [optional] {
Configuration options.

@type int $maxResults The maximum number of rows to return per page
of results. Setting this flag to a small value such as 1000 and
then paging through results might improve reliability when the
query result set is large.
@type int $startIndex Zero-based index of the starting row.
@type int $timeoutMs How long, in milliseconds, each API call will
wait for query results to become available before timing out.
Depending on whether the $maxRetries has been exceeded, the
results will be polled again after the timeout has been reached.
**Defaults to** `10000` milliseconds (10 seconds).
@type int $maxRetries The number of times to poll the Job status,
until the job is complete. By default, will poll indefinitely.
}
@return QueryResults
@throws JobException If the maximum number of retries while waiting for
query completion has been exceeded.
Runs a BigQuery SQL query in a synchronous fashion .