Deleting an item from the DynamoDB table using the AWS SDK for PHP
Let's understand how to delete an item from the DynamoDB table using the AWS SDK for PHP.
Getting ready
To perform this operation, you can use the IDE of your choice.
How to do it…
Let's try to understand how to delete a stored item from the DynamoDB table using PHP:
Create an instance of the DynamoDB client and initiate it with the desired AWS region and credentials:
$client = DynamoDbClient::factory(array( 'profile' => 'default', 'region' => 'us-east-1' ));
Invoke the
deleteItem
method specifying the primary key of the item to be deleted:$response = $client->deleteItem(array( 'TableName' => 'productTable', 'Key' => array( 'id' => array( 'N' => 30 ), 'type' => array( 'S' => 'phone' ) ) ));
How it works…
The API invocations call the DynamoDB services and delete the item from the specified table. Once the data has been deleted, there...