- 1.104.0 (latest)
- 1.103.0
- 1.102.0
- 1.101.0
- 1.100.0
- 1.98.0
- 1.97.0
- 1.96.0
- 1.95.0
- 1.94.0
- 1.93.1
- 1.92.1
- 1.91.0
- 1.90.0
- 1.89.0
- 1.88.0
- 1.87.0
- 1.86.0
- 1.85.0
- 1.84.0
- 1.83.0
- 1.82.0
- 1.81.0
- 1.80.0
- 1.79.0
- 1.78.0
- 1.77.0
- 1.76.1
- 1.68.0
- 1.67.0
- 1.66.0
- 1.65.0
- 1.64.0
- 1.63.2
- 1.62.1
- 1.61.0
- 1.60.0
- 1.59.0
- 1.58.4
- 1.57.0
- 1.56.0
- 1.55.0
- 1.54.2
Reference documentation and code samples for the Cloud Spanner Client class Result.
Represent a Cloud Spanner lookup result (either read or executeSql).
Example:
use Google\Cloud\Spanner\SpannerClient;
$spanner = new SpannerClient();
$database = $spanner->connect('my-instance', 'my-database');
$result = $database->execute('SELECT * FROM Posts');
Namespace
Google \ Cloud \ SpannerMethods
__construct
operation
session
call
callable
A callable, yielding a generator filled with results.
transactionContext
string
The transaction's context.
mapper
retries
int
Number of attempts to resume a broken stream, assuming a resume token is present. Defaults to3.
rows
Return the formatted and decoded rows. If the stream is interrupted and a resume token is available, attempts will be made on your behalf to resume.
Example:
$rows = $result->rows();
format
string
Determines the format in which rows are returned. Result::RETURN_NAME_VALUE_PAIR
returns items as a
multi-dimensional array containing a name and a value key.
Ex: [0 => ['name' => 'column1', 'value' => 'my_value']]
. Result::RETURN_ASSOCIATIVE
returns items as an associative array
with the column name as the key. Please note with this option, if
duplicate column names are present a \RuntimeException
will be
thrown. Result::RETURN_ZERO_INDEXED
returns items as a 0 indexed
array, with the key representing the column number as found by
executing Result::columns()
. Ex: [0 => 'my_value']
. Defaults to Result::RETURN_ASSOCIATIVE
.
Generator
columns
Return column names.
Will be populated once the result set is iterated upon.
Example:
$columns = $result->columns();
array|null
metadata
Return result metadata.
Will be populated once the result set is iterated upon.
Example:
$metadata = $result->metadata();
array|null
session
Return the session associated with the result stream.
Example:
$session = $result->session();
stats
Get the query plan and execution statistics for the query that produced this result set.
By default, statistics are returned by default only when executing a DML
statement. To receive statistics for a SELECT statement, set $options.queryMode
to Result::MODE_PROFILE
, as demonstrated below.
Setting $options.queryMode
to Result::MODE_PLAN
will return the query
plan without any results or execution statistics information.
Example:
$stats = $result->stats();
// Executing a query with stats returned.
use Google\Cloud\Spanner\Result;
$res = $database->execute('SELECT * FROM Posts', [
'queryMode' => Result::MODE_PROFILE
]);
array|null
snapshot
Returns a snapshot which was begun in the read or execute, if one exists.
Will be populated once the result set is iterated upon.
Example:
$snapshot = $result->snapshot();
transaction
Returns a transaction which was begun in the read or execute, if one exists.
Will be populated once the result set is iterated upon.
Example:
$transaction = $result->transaction();
getIterator
Generator
Constants
BUFFER_RESULT_LIMIT
Value: 10
RETURN_NAME_VALUE_PAIR
Value: 'nameValuePair'
RETURN_ASSOCIATIVE
Value: 'associative'
RETURN_ZERO_INDEXED
Value: 'zeroIndexed'
MODE_NORMAL
Value: \Google\Cloud\Spanner\V1\ExecuteSqlRequest\QueryMode::NORMAL
MODE_PLAN
Value: \Google\Cloud\Spanner\V1\ExecuteSqlRequest\QueryMode::PLAN
MODE_PROFILE
Value: \Google\Cloud\Spanner\V1\ExecuteSqlRequest\QueryMode::PROFILE