Use the putRow method in the PHP SDK to write a single row of data to a Tablestore table.
Before you begin
Method description
public function putRow(array $request)
Sample code
Write one row of data to the test_table table with a primary key value of row1.
$request = array (
'table_name' => 'test_table',
// Build the primary key
'primary_key' => array (
array('id', 'row1')
)
);
try{
// Call putRow to write the row
$response = $client->putRow($request);
echo "* Read CU Cost: " . $response['consumed']['capacity_unit']['read'] . "\n";
echo "* Write CU Cost: " . $response['consumed']['capacity_unit']['write'] . "\n";
} catch (Exception $e) {
echo "Put Row failed.";
}
-
Add an attribute column.
$request['attribute_columns'] = array( array('col1', 'val1') ); -
Specify a version number. Assign a separate version number to each attribute column.
$request['attribute_columns'] = array( array('col1', 'val1', null, intval(microtime(true) * 1000)) );