本文介紹如何使用 PHP SDK 刪除Table Store資料表的單行資料。
前提條件
方法說明
public function deleteRow(array $request)範例程式碼
以下範例程式碼用於刪除 test_table 表中主索引值為 row1 的行資料。
try{
$response = $client->deleteRow(array (
'table_name' => 'test_table',
'primary_key' => array (
array ('id', 'row1')
),
// 刪除行資料時必須配置刪除條件 (RowExistenceExpectationConst::CONST_IGNORE,表示不做行存在性判斷)
'condition' => RowExistenceExpectationConst::CONST_IGNORE
));
echo "Read CU Cost: " . $response['consumed']['capacity_unit']['read'] . "\n";
echo "Write CU Cost: " . $response['consumed']['capacity_unit']['write'] . "\n";
} catch (Exception $e) {
echo "Delete Row failed.";
}