Read Records
GetResult get(GetRequest request)
Function
Get a row of record of any table, able to return all attributes or partial attributes
Consume one unit of read quota
Method parameters
request : GetRequest : required
GetRequest includes the following sections
1.tableName : String : required
Specifies which table to read
2.keys : Map< String, Datum > : required
Specifies which line to read, ie the entity group key for that row (if any) and the attribute value of the primary key; keys must contain all entity group keys (if any) and the primary key attributes
3.attributes : List< String > : optional
Specifies the list of attributes that need to be returned, without specifying that all attributes are returned
Method return value
item : Map< String, Datum >
The value of the specified attribute returned
Exception error code
INTERNAL_ERROR(1): Server exception
ACCESS_DENIED(4): User does not have read permission for this table
VALIDATION_FAILED(5): keys do not completely contain the entity group key (if any) and the primary key attributes, or the specified attribute does not exist
THROUGHPUT_EXCEED(8): The current read/write speed has exceeded the read/write quota for this table
RESOURCE_NOT_FOUND(9): Specified table does not exist
Limitation
keys must contain the entity group key (if any) and the attributes of the primary key
Example
With the Example table, the sample code for reading table is provided below
$tableName = 'php-note';
$get = new GetRequest(array(
"tableName" => $tableName,
"keys" => array(
"userId" => DatumUtil::datum("user1"),
"noteId" => DatumUtil::datum(rand(0, 10)),
),
));
$result = $tableClient->get($get);