Cloud Spanner Client - Class KeySet (1.82.0)

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

Represents a Cloud Spanner KeySet.

Example:

use Google\Cloud\Spanner\SpannerClient;

$spanner = new SpannerClient();

$keySet = $spanner->keySet();

Namespace

Google \ Cloud \ Spanner

Methods

__construct

Create a KeySet.

Parameters
Name Description
options array

[optional] { @type array $keys A list of specific keys. Entries in keys should have exactly as many elements as there are columns in the primary or index key with which this KeySet is used. @type KeyRange[] $ranges A list of Key Ranges. @type bool $all If true, KeySet will match all keys in a table. Defaults to false. }

↳ keys array

A list of specific keys. Entries in keys should have exactly as many elements as there are columns in the primary or index key with which this KeySet is used.

↳ ranges KeyRange[]

A list of Key Ranges.

↳ all bool

If true, KeySet will match all keys in a table. Defaults to false.

ranges

Fetch the KeyRanges

Example:

$ranges = $keySet->ranges();
Returns
Type Description
array<Google\Cloud\Spanner\KeyRange>

addRange

Add a single KeyRange.

Example:

$range = new KeyRange();
$keySet->addRange($range);
Parameter
Name Description
range Google\Cloud\Spanner\KeyRange

A KeyRange instance.

Returns
Type Description
void

setRanges

Set the KeySet's KeyRanges.

Any existing KeyRanges will be overridden.

Example:

$range = new KeyRange();
$keySet->setRanges([$range]);
Parameter
Name Description
ranges array<Google\Cloud\Spanner\KeyRange>

An array of KeyRange objects.

Returns
Type Description
void

keys

Fetch the keys.

Example:

$keys = $keySet->keys();
Returns
Type Description
array

addKey

Add a single key.

A Key should have exactly as many elements as there are columns in the primary or index key with which this KeySet is used.

Example:

$keySet->addKey('Bob');
Parameter
Name Description
key mixed

The Key to add.

Returns
Type Description
void

setKeys

Set the KeySet keys.

Any existing keys will be overridden.

Example:

$keySet->setKeys(['Bob', 'Jill']);
Parameter
Name Description
keys array
Returns
Type Description
void

matchAll

Get the value of Match All.

Example:

if ($keySet->matchAll()) {
    echo "All keys will match";
}
Returns
Type Description
bool

setMatchAll

Choose whether the KeySet should match all keys in a table.

Example:

$keySet->setMatchAll(true);
Parameter
Name Description
all bool

If true, all keys in a table will be matched.

Returns
Type Description
void

keySetObject

Format a KeySet object for use in the Spanner API.

static::fromArray

Create a KeySet from an array created by Google\Cloud\Spanner\KeySet::keySetObject().

Parameter
Name Description
keySet array

An array of KeySet data.

Returns
Type Description
Google\Cloud\Spanner\KeySet