Birincil anahtarını belirterek Tablestore tablosundan tek bir veri satırını okumak için PHP SDK'yı kullanın.
Kullanım notları
Veri okurken otomatik artan birincil anahtar sütun değeri dahil olmak üzere tam birincil anahtar değerini sağlamanız gerekir.
Ön koşullar
Yöntem açıklaması
public function getRow(array $request)
Örnek kod
Aşağıdaki örnekte birincil anahtar değeri row1 olan bir satır okunur.
$request = array (
'table_name' => 'test_table',
// Construct primary key
'primary_key' => array (
array ('id', 'row1')
),
'max_versions' => 1
);
try {
// Call the getRow method to read row data
$response = $client->getRow ($request);
echo "* Read CU Cost: " . $response['consumed']['capacity_unit']['read'] . "\n";
echo "* Write CU Cost: " . $response['consumed']['capacity_unit']['write'] . "\n";
echo "* Row Data: " . "\n";
echo "Primary Key: ". json_encode($response['primary_key']) . "\n";
echo "Attribute Columns: ". json_encode($response['attribute_columns']) . "\n";
} catch (Exception $e){
echo "Get Row failed.";
}
-
Yalnızca belirli bir aralıktaki verileri döndürmek için bir sürüm aralığı ayarlayın.
// Set the query data version range to one day before the current time $request['time_range'] = array ( 'start_time' => intval(microtime(true) * 1000) - 86400 * 1000, 'end_time' => intval(microtime(true) * 1000) ); -
Okunacak nitelik sütunlarını belirtin.
$request['columns_to_get'] = array('col2');