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 tofalse.
}
↳ 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 tofalse.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Cloud Spanner Client - Class KeySet (1.104.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.104.0 (latest)](/php/docs/reference/cloud-spanner/latest/KeySet)\n- [1.103.0](/php/docs/reference/cloud-spanner/1.103.0/KeySet)\n- [1.102.0](/php/docs/reference/cloud-spanner/1.102.0/KeySet)\n- [1.101.0](/php/docs/reference/cloud-spanner/1.101.0/KeySet)\n- [1.100.0](/php/docs/reference/cloud-spanner/1.100.0/KeySet)\n- [1.98.0](/php/docs/reference/cloud-spanner/1.98.0/KeySet)\n- [1.97.0](/php/docs/reference/cloud-spanner/1.97.0/KeySet)\n- [1.96.0](/php/docs/reference/cloud-spanner/1.96.0/KeySet)\n- [1.95.0](/php/docs/reference/cloud-spanner/1.95.0/KeySet)\n- [1.94.0](/php/docs/reference/cloud-spanner/1.94.0/KeySet)\n- [1.93.1](/php/docs/reference/cloud-spanner/1.93.1/KeySet)\n- [1.92.1](/php/docs/reference/cloud-spanner/1.92.1/KeySet)\n- [1.91.0](/php/docs/reference/cloud-spanner/1.91.0/KeySet)\n- [1.90.0](/php/docs/reference/cloud-spanner/1.90.0/KeySet)\n- [1.89.0](/php/docs/reference/cloud-spanner/1.89.0/KeySet)\n- [1.88.0](/php/docs/reference/cloud-spanner/1.88.0/KeySet)\n- [1.87.0](/php/docs/reference/cloud-spanner/1.87.0/KeySet)\n- [1.86.0](/php/docs/reference/cloud-spanner/1.86.0/KeySet)\n- [1.85.0](/php/docs/reference/cloud-spanner/1.85.0/KeySet)\n- [1.84.0](/php/docs/reference/cloud-spanner/1.84.0/KeySet)\n- [1.83.0](/php/docs/reference/cloud-spanner/1.83.0/KeySet)\n- [1.82.0](/php/docs/reference/cloud-spanner/1.82.0/KeySet)\n- [1.81.0](/php/docs/reference/cloud-spanner/1.81.0/KeySet)\n- [1.80.0](/php/docs/reference/cloud-spanner/1.80.0/KeySet)\n- [1.79.0](/php/docs/reference/cloud-spanner/1.79.0/KeySet)\n- [1.78.0](/php/docs/reference/cloud-spanner/1.78.0/KeySet)\n- [1.77.0](/php/docs/reference/cloud-spanner/1.77.0/KeySet)\n- [1.76.1](/php/docs/reference/cloud-spanner/1.76.1/KeySet)\n- [1.68.0](/php/docs/reference/cloud-spanner/1.68.0/KeySet)\n- [1.67.0](/php/docs/reference/cloud-spanner/1.67.0/KeySet)\n- [1.66.0](/php/docs/reference/cloud-spanner/1.66.0/KeySet)\n- [1.65.0](/php/docs/reference/cloud-spanner/1.65.0/KeySet)\n- [1.64.0](/php/docs/reference/cloud-spanner/1.64.0/KeySet)\n- [1.63.2](/php/docs/reference/cloud-spanner/1.63.2/KeySet)\n- [1.62.1](/php/docs/reference/cloud-spanner/1.62.1/KeySet)\n- [1.61.0](/php/docs/reference/cloud-spanner/1.61.0/KeySet)\n- [1.60.0](/php/docs/reference/cloud-spanner/1.60.0/KeySet)\n- [1.59.0](/php/docs/reference/cloud-spanner/1.59.0/KeySet)\n- [1.58.4](/php/docs/reference/cloud-spanner/1.58.4/KeySet)\n- [1.57.0](/php/docs/reference/cloud-spanner/1.57.0/KeySet)\n- [1.56.0](/php/docs/reference/cloud-spanner/1.56.0/KeySet)\n- [1.55.0](/php/docs/reference/cloud-spanner/1.55.0/KeySet)\n- [1.54.2](/php/docs/reference/cloud-spanner/1.54.2/KeySet) \nReference documentation and code samples for the Cloud Spanner Client class KeySet.\n\nRepresents a Cloud Spanner KeySet.\n\nExample: \n\n use Google\\Cloud\\Spanner\\SpannerClient;\n\n $spanner = new SpannerClient();\n\n $keySet = $spanner-\u003ekeySet();\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ Spanner\n\nMethods\n-------\n\n### __construct\n\nCreate a KeySet.\n\n### ranges\n\nFetch the KeyRanges\n\nExample: \n\n $ranges = $keySet-\u003eranges();\n\n### addRange\n\nAdd a single KeyRange.\n\nExample: \n\n $range = new KeyRange();\n $keySet-\u003eaddRange($range);\n\n### setRanges\n\nSet the KeySet's KeyRanges.\n\nAny existing KeyRanges will be overridden.\n\nExample: \n\n $range = new KeyRange();\n $keySet-\u003esetRanges([$range]);\n\n### keys\n\nFetch the keys.\n\nExample: \n\n $keys = $keySet-\u003ekeys();\n\n### addKey\n\nAdd a single key.\n\nA Key should have exactly as many elements as there are columns in the\nprimary or index key with which this KeySet is used.\n\nExample: \n\n $keySet-\u003eaddKey('Bob');\n\n### setKeys\n\nSet the KeySet keys.\n\nAny existing keys will be overridden.\n\nExample: \n\n $keySet-\u003esetKeys(['Bob', 'Jill']);\n\n### matchAll\n\nGet the value of Match All.\n\nExample: \n\n if ($keySet-\u003ematchAll()) {\n echo \"All keys will match\";\n }\n\n### setMatchAll\n\nChoose whether the KeySet should match all keys in a table.\n\nExample: \n\n $keySet-\u003esetMatchAll(true);\n\n### keySetObject\n\nFormat a KeySet object for use in the Spanner API.\n\n### static::fromArray\n\nCreate a KeySet from an array created by [KeySet::keySetObject()](/php/docs/reference/cloud-spanner/latest/KeySet#_Google_Cloud_Spanner_KeySet__keySetObject__)."]]