Cloud Spanner Client - Class BatchDmlResult (1.89.0)

Reference documentation and code samples for the Cloud Spanner Client class BatchDmlResult.

Represents the result of a Batch DML operation.

Example:

use Google\Cloud\Spanner\SpannerClient;
use Google\Cloud\Spanner\Transaction;

$spanner = new SpannerClient();
$database = $spanner->connect('my-instance', 'my-database');

$batchDmlResult = $database->runTransaction(function (Transaction $t) {
    $result = $t->executeUpdateBatch([
        [
            'sql' => 'UPDATE posts SET author = @author WHERE id = @id',
            'params' => [
                'author' => 'John',
                'id' => 1
            ]
        ]
    ]);

    $t->commit();

    return $result;
});

Namespace

Google \ Cloud \ Spanner

Methods

__construct

Parameters
Name Description
data array

The executeBatchDml response data.

errorStatement array|null

The statement (with params and types) which triggered an error.

rowCounts

Get a list of integers indicating the number of modified rows for each successful statement.

Example:

$counts = $batchDmlResult->rowCounts();
Returns
Type Description
int[]

error

Get a Batch DML error, if one exists.

If an error occurred, the method returns an array, where the status key contains error information, represented as google.rpc.Status, and the 'statement` key contains the input which caused the error.

If no error occurred, this method returns null.

Example:

$error = $batchDmlResult->error();
Returns
Type Description
array|null