Installation guide

If you have a large array of items you wish to add to your table, you could iterate over the them, add each item to the
batch object. After all the items are added call flush(). The batch object will automatically flush the batch and
write items to Amazon DynamoDB after hitting a customizable threshold. A final call to the batch object's flush()
method is necessary to transfer any remaining items in the queue.
$tableName = 'batch-write-test'; // This table has a HashKey named "id"
$itemIds = array();
// Put 55 items into the table
$putBatch = WriteRequestBatch::factory($client);
for ($i = 0; $i < 55; $i++) {
$itemIds[] = $itemId = uniqid();
$item = Item::fromArray(array(
'id' => $itemId,
'timestamp' => time(),
));
$putBatch->add(new PutRequest($item, $tableName));
}
$putBatch->flush();
You can also use the WriteRequestBatch object to delete items in batches.
// Remove items from the table
$deleteBatch = WriteRequestBatch::factory($client);
foreach ($itemIds as $itemId) {
$key = array('HashKeyElement' => array('S' => $itemId));
$deleteBatch->add(new DeleteRequest($key, $tableName));
}
$deleteBatch->flush();
The WriteRequestBatch, PutRequest, and DeleteRequest classes are all a part of the
Aws\DynamoDb\Model\BatchRequest namespace.
API Reference
Please see the Amazon DynamoDB Client API reference for a details about all of the available methods, including
descriptions of the inputs and outputs.
BatchGetItem BatchWriteItem
CreateTable DeleteItem
DeleteTable DescribeTable
GetItem ListTables
PutItem Query
Scan UpdateItem
UpdateTable
Amazon Elastic Compute Cloud
This guide focuses on the AWS SDK for PHP client for Amazon Elastic Compute Cloud. This guide assumes that
you have already downloaded and installed the AWS SDK for PHP. See Installation for more information on getting
started.
Creating a client
First you need to create a client object using one of the following techniques.
Factory method
Amazon Elastic Compute Cloud
79