Appelez la méthode putRow du SDK PHP pour écrire une seule ligne de données dans une table Tablestore.
Avant de commencer
Description de la méthode
public function putRow(array $request)
Exemple de code
L'exemple suivant écrit une ligne dans la table test_table avec une valeur de clé primaire 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.";
}
-
Ajoutez une colonne d'attribut.
$request['attribute_columns'] = array( array('col1', 'val1') ); -
Spécifiez un numéro de version. Attribuez un numéro de version distinct à chaque colonne d'attribut.
$request['attribute_columns'] = array( array('col1', 'val1', null, intval(microtime(true) * 1000)) );