Cloud Spanner Client - Class CommitTimestamp (1.83.0)

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

A special value which, when used, will set the field value to the value of the commit timestamp.

Cloud Spanner allows users to designate a specific Timestamp column in the table schema to contain commit timestamps. When writing to this column, a manually-created timestamp (in the past) may be supplied, or Cloud Spanner can populate it server-side.

Note that this special value cannot be used unless the column has been annotated with support for commit timestamps:

CREATE TABLE myTable (
    id STRING(100) NOT NULL,
    commitTimestamp TIMESTAMP NOT NULL OPTIONS
        (allow_commit_timestamp=true)
) PRIMARY KEY(id, commitTimestamp DESC)

Example:

use Google\Cloud\Spanner\SpannerClient;

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

$database->insert('myTable', [
    'id' => $id,
    'commitTimestamp' => $spanner->commitTimestamp()
]);

Namespace

Google \ Cloud \ Spanner

Methods

type

get

formatAsString

__toString

Constants

SPECIAL_VALUE

Value: 'spanner.commit_timestamp()'