Cloud Spanner Client - Class KeySet (1.76.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
NameDescription
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
TypeDescription
array<Google\Cloud\Spanner\KeyRange>

addRange

Add a single KeyRange.

Example:

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

A KeyRange instance.

Returns
TypeDescription
void

setRanges

Set the KeySet's KeyRanges.

Any existing KeyRanges will be overridden.

Example:

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

An array of KeyRange objects.

Returns
TypeDescription
void

keys

Fetch the keys.

Example:

$keys = $keySet->keys();
Returns
TypeDescription
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
NameDescription
key mixed

The Key to add.

Returns
TypeDescription
void

setKeys

Set the KeySet keys.

Any existing keys will be overridden.

Example:

$keySet->setKeys(['Bob', 'Jill']);
Parameter
NameDescription
keys array
Returns
TypeDescription
void

matchAll

Get the value of Match All.

Example:

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

setMatchAll

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

Example:

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

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

Returns
TypeDescription
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
NameDescription
keySet array

An array of KeySet data.

Returns
TypeDescription
Google\Cloud\Spanner\KeySet