PHP Class Google\Cloud\BigQuery\QueryResults

This class should be not instantiated directly, but as a result of calling {@see \Google\Cloud\BigQuery\BigQueryClient::runQuery()} or {@see \Google\Cloud\BigQuery\Job::queryResults()}.
Afficher le fichier Open project: GoogleCloudPlatform/gcloud-php

Protected Properties

Свойство Type Description
$connection Google\Cloud\BigQuery\Connection\ConnectionInterface Represents a connection to BigQuery.

Méthodes publiques

Méthode Description
__construct ( Google\Cloud\BigQuery\Connection\ConnectionInterface $connection, string $jobId, string $projectId, array $info, array $reloadOptions, ValueMapper $mapper )
identity ( ) : array Retrieves the query result's identity.
info ( ) : array Retrieves the cached query details.
isComplete ( ) : boolean Checks the query's completeness. Useful in combination with {@see Google\Cloud\BigQuery\QueryResults::reload()} to poll for query status.
reload ( array $options = [] ) : array Triggers a network request to reload the query's details.
rows ( array $options = [] ) : array Retrieves the rows associated with the query and merges them together with the table's schema. It is recommended to check the completeness of the query before attempting to access rows.

Method Details

__construct() public méthode

public __construct ( Google\Cloud\BigQuery\Connection\ConnectionInterface $connection, string $jobId, string $projectId, array $info, array $reloadOptions, ValueMapper $mapper )
$connection Google\Cloud\BigQuery\Connection\ConnectionInterface Represents a connection to BigQuery.
$jobId string The job's ID.
$projectId string The project's ID.
$info array The query result's metadata.
$reloadOptions array The options to use when reloading query data.
$mapper ValueMapper Maps values between PHP and BigQuery.

identity() public méthode

An identity provides a description of a nested resource. Example: echo $queryResults->identity()['projectId'];
public identity ( ) : array
Résultat array

info() public méthode

Example: $info = $queryResults->info(); echo $info['totalBytesProcessed'];
See also: https://cloud.google.com/bigquery/docs/reference/v2/jobs/getQueryResults#response Jobs getQueryResults API response documentation.
public info ( ) : array
Résultat array

isComplete() public méthode

Example: $isComplete = $queryResults->isComplete(); while (!$isComplete) { sleep(1); // small delay between requests $queryResults->reload(); $isComplete = $queryResults->isComplete(); } echo 'Query complete!';
public isComplete ( ) : boolean
Résultat boolean

reload() public méthode

Useful when needing to poll an incomplete query for status. Configuration options will be inherited from {@see \Google\Cloud\BigQuery\Job::queryResults()} or {@see \Google\Cloud\BigQuery\BigQueryClient::runQuery()}, but they can be overridden if needed. Example: $queryResults->isComplete(); // returns false sleep(1); // let's wait for a moment... $queryResults->reload(); // executes a network request if ($queryResults->isComplete()) { echo "Query complete!"; }
See also: https://cloud.google.com/bigquery/docs/reference/v2/jobs/getQueryResults Jobs getQueryResults API documentation.
public reload ( array $options = [] ) : array
$options array [optional] { Configuration options. @type int $maxResults Maximum number of results to read. @type int $startIndex Zero-based index of the starting row. @type int $timeoutMs How long to wait for the query to complete, in milliseconds. **Defaults to** `10000` milliseconds (10 seconds). }
Résultat array

rows() public méthode

Refer to the table below for a guide on how BigQuery types are mapped as they come back from the API. | **PHP Type** | **BigQuery Data Type** | |--------------------------------------------|--------------------------------------| | \DateTimeInterface | DATETIME | | {@see \Google\Cloud\BigQuery\Bytes} | BYTES | | {@see \Google\Cloud\BigQuery\Date} | DATE | | {@see \Google\Cloud\Int64} | INTEGER | | {@see \Google\Cloud\BigQuery\Time} | TIME | | {@see \Google\Cloud\BigQuery\Timestamp} | TIMESTAMP | | Associative Array | RECORD | | Non-Associative Array | RECORD (Repeated) | | float | FLOAT | | int | INTEGER | | string | STRING | | bool | BOOLEAN | Example: $isComplete = $queryResults->isComplete(); if ($isComplete) { $rows = $queryResults->rows(); foreach ($rows as $row) { echo $row['name'] . PHP_EOL; } }
public rows ( array $options = [] ) : array
$options array [optional] Configuration options.
Résultat array

Property Details

$connection protected_oe property

Represents a connection to BigQuery.
protected ConnectionInterface,Google\Cloud\BigQuery\Connection $connection
Résultat Google\Cloud\BigQuery\Connection\ConnectionInterface