Installation guide
$people = array();
// Perform as many Scan operations as needed to acquire all the names of people
// that are 16 or older
do
{
// Setup the parameters for the DynamoDB Scan operation
$params = array(
'TableName' => 'people',
'AttributesToGet' => array('id', 'age', 'name'),
'ScanFilter' => array(
'age' => array(
'ComparisonOperator' =>
AmazonDynamoDB::CONDITION_GREATER_THAN_OR_EQUAL,
'AttributeValueList' => array(
array(AmazonDynamoDB::TYPE_NUMBER => '16')
)
),
)
);
// Add the exclusive start key parameter if needed
if ($start_key)
{
$params['ExclusiveStartKey'] = array(
'HashKeyElement' => array(
AmazonDynamoDB::TYPE_STRING => $start_key
)
);
$start_key = null;
}
// Perform the Scan operation and get the response
$response = $dynamo_db->scan($params);
// If the response succeeded, get the results
if ($response->isOK())
{
foreach ($response->body->Items as $item)
{
$people[] = (string) $item->name->{AmazonDynamoDB::TYPE_STRING};
}
// Get the last evaluated key if it is provided
if ($response->body->LastEvaluatedKey)
{
$start_key = (string) $response->body
->LastEvaluatedKey
->HashKeyElement
->{AmazonDynamoDB::TYPE_STRING};
}
}
else
{
// Throw an exception if the response was not OK (200-level)
throw new DynamoDB_Exception('DynamoDB Scan operation failed.');
}
}
while ($start_key);
Migration Guide
14