Installation guide
Let's say we want a list of all "1201" errors that occurred in the last 15 minutes. We could issue a single query that
will search by the primary key of the table and retrieve up to 1MB of the items. However, a better approach is to use
the query iterator to retrieve the entire list of all items matching the query.
$iterator = $client->getIterator('Query', array(
'TableName' => 'errors',
'KeyConditions' => array(
'id' => array(
'AttributeValueList' => array(
array('N' => '1201')
),
'ComparisonOperator' => 'EQ'
),
'time' => array(
'AttributeValueList' => array(
array('N' => strtotime("-15 minutes"))
),
'ComparisonOperator' => 'GT'
)
)
));
// Each item will contain the attributes we added
foreach ($iterator as $item) {
// Grab the time number value
echo $item['time']['N'] . "\n";
// Grab the error string value
echo $item['error']['S'] . "\n";
}
Scan
A scan operation scans the entire table. You can specify filters to apply to the results to refine the values returned to
you, after the complete scan. Amazon DynamoDB puts a 1MB limit on the scan (the limit applies before the results
are filtered).
A scan can be useful for more complex searches. For example, we can retrieve all of the errors in the last 15
minutes that contain the word "overflow":
$iterator = $client->getIterator('Scan', array(
'TableName' => 'errors',
'ScanFilter' => array(
'error' => array(
'AttributeValueList' => array(
array('S' => 'overflow')
),
'ComparisonOperator' => 'CONTAINS'
),
'time' => array(
'AttributeValueList' => array(
array('N' => strtotime('-15 minutes'))
),
'ComparisonOperator' => 'GT'
)
)
));
// Each item will contain the attributes we added
foreach ($iterator as $item) {
// Grab the time number value
echo $item['time']['N'] . "\n";
// Grab the error string value
Amazon DynamoDB
69