Installation guide

Tip
You can convert an iterator to an array using the toArray() method of the iterator.
Adding items
You can add an item to our errors table using the putItem() method of the client.
$time = time();
$result = $client->putItem(array(
'TableName' => 'errors',
'Item' => $client->formatAttributes(array(
'id' => 1201,
'time' => $time,
'error' => 'Executive overflow',
'message' => 'no vacant areas'
))
));
// The result will always contain ConsumedCapacityUnits
echo $result['ConsumedCapacityUnits'] . "\n";
As you can see, the formatAttributes() method of the client can be used to more easily format the attributes
of the item. Alternatively, you can provide the item attributes without using the helper method:
$result = $client->putItem(array(
'TableName' => 'errors',
'Item' => array(
'id' => array('N' => '1201'),
'time' => array('N' => $time),
'error' => array('S' => 'Executive overflow'),
'message' => array('S' => 'no vacant areas')
)
));
Retrieving items
You can check if the item was added correctly using the getItem() method of the client. Because Amazon
DynamoDB works under an 'eventual consistency' model, we need to specify that we are performing a consistent
read operation.
$result = $client->getItem(array(
'ConsistentRead' => true,
'TableName' => 'errors',
'Key' => array(
'HashKeyElement' => array('N' => '1201'),
'RangeKeyElement' => array('N' => $time)
)
));
// Grab value from the result object like an array
echo $result['Item']['id']['N'] . "\n";
//> 1201
echo $result->getPath('Item/id/N') . "\n";
//> 1201
echo $result['Item']['error']['S'] . "\n";
//> Executive overflow
Amazon DynamoDB (2011-12-05)
76