Spanner/src/Database.php
public function snapshot(array $options = [])
    {
        if ($this->isRunningTransaction) {
            throw new \BadMethodCallException('Nested transactions are not supported by this client.');
        }

        $options += [
            'singleUse' => false
        ];

        $options['transactionOptions'] = $this->configureSnapshotOptions($options);

        $session = $this->selectSession(
            SessionPoolInterface::CONTEXT_READ,
            $this->pluck('sessionOptions', $options, false) ?: []
        );

        try {
            return $this->operation->snapshot($session, $options);
        } finally {
            $session->setExpiration();
        }
    }
public function snapshot(array $options = [])
    {
        if ($this->isRunningTransaction) {
            throw new \BadMethodCallException('Nested transactions are not supported by this client.');
        }

        $options += [
            'singleUse' => false
        ];

        $options['transactionOptions'] = $this->configureSnapshotOptions($options);

        $session = $this->selectSession(
            SessionPoolInterface::CONTEXT_READ,
            $this->pluck('sessionOptions', $options, false) ?: []
        );

        try {
            return $this->operation->snapshot($session, $options);
        } finally {
            $session->setExpiration();
        }
    }
public function snapshot ( array $ options = [ ] ) { if ( $ this -> isRunningTransaction ) { throw new \ BadMethodCallException ( 'Nested transactions are not supported by this client.' ) ; } $ options += [ 'singleUse' => false ] ; $ options [ 'transactionOptions' ] = $ this -> configureSnapshotOptions ( $ options ) ; $ session = $ this -> selectSession ( SessionPoolInterface :: CONTEXT_READ , $ this -> pluck ( 'sessionOptions' , $ options , false ) ? : [ ] ) ; try { return $ this -> operation -> snapshot ( $ session , $ options ) ; } finally { $ session -> setExpiration ( ) ; } }
Create a snapshot to read from a database at a point in time.

If no configuration options are provided, transaction will be opened with
strong consistency.

Snapshots are executed behind the scenes using a Read-Only Transaction.

Example:
```
$snapshot = $database->snapshot();
```

```
// Take a shapshot with a returned timestamp.
$snapshot = $database->snapshot([
'returnReadTimestamp' => true
]);

$timestamp = $snapshot->readTimestamp();
```

@codingStandardsIgnoreStart
@see https://cloud.google.com/spanner/reference/rpc/google.spanner.v1#google.spanner.v1.BeginTransactionRequest BeginTransactionRequest
@see https://cloud.google.com/spanner/docs/transactions Transactions

@param array $options [optional] {
Configuration Options

See [ReadOnly](https://cloud.google.com/spanner/reference/rpc/google.spanner.v1#google.spanner.v1.TransactionOptions.ReadOnly)
for detailed description of available options.

Please note that only one of `$strong`, `$readTimestamp` or
`$exactStaleness` may be set in a request.

@type bool $returnReadTimestamp If true, the Cloud Spanner-selected
read timestamp is included in the Transaction message that
describes the transaction.
@type bool $strong Read at a timestamp where all previously committed
transactions are visible.
@type Timestamp $readTimestamp Executes all reads at the given
timestamp.
@type Duration $exactStaleness Represents a number of seconds. Executes
all reads at a timestamp that is $exactStaleness old.
@type Timestamp $minReadTimestamp Executes all reads at a
timestamp >= min_read_timestamp. Only available when
`$options.singleUse` is true.
@type Duration $maxStaleness Read data at a timestamp >= NOW - max_staleness
seconds. Guarantees that all writes that have committed more
than the specified number of seconds ago are visible. Only
available when `$options.singleUse` is true.
@type bool $singleUse If true, a Transaction ID will not be allocated
up front. Instead, the transaction will be considered
"single-use", and may be used for only a single operation.
**Defaults to** `false`.
@type array $sessionOptions Session configuration and request options.
Session labels may be applied using the `labels` key.
}
@return Snapshot
@throws \BadMethodCallException If attempting to call this method within
an existing transaction.
@codingStandardsIgnoreEnd
Create a snapshot to read from a database at a point in time .