-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathquery_dynamo.php
More file actions
executable file
·36 lines (30 loc) · 1.13 KB
/
query_dynamo.php
File metadata and controls
executable file
·36 lines (30 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
// If necessary, reference the sdk.class.php file.
// For example, the following line assumes the sdk.class.php file is
// in an sdk sub-directory relative to this file
require_once dirname(__FILE__) . '/vendor/amazonwebservices/aws-sdk-for-php/sdk.class.php';
// Instantiate the class.
$dynamodb = new AmazonDynamoDB(array(
'key' => getenv('AWS_ACCESS_KEY'),
'secret' => getenv('AWS_SECRET_KEY'),
));
$dynamodb->set_region('dynamodb.'.getenv('AWS_REGION').'.amazonaws.com');
$fourteen_days_ago = date('Y-m-d H:i:s', strtotime("-14 days"));
$response = $dynamodb->query(array(
'TableName' => 'Reply',
'HashKeyValue' => array(
AmazonDynamoDB::TYPE_STRING => 'Amazon DynamoDB#DynamoDB Thread 2',
),
'RangeKeyCondition' => array(
'ComparisonOperator' => AmazonDynamoDB::CONDITION_GREATER_THAN_OR_EQUAL,
'AttributeValueList' => array(
array(
AmazonDynamoDB::TYPE_STRING => $fourteen_days_ago
)
)
)
));
header('content-type: text/plain');
// Response code 200 indicates success
print_r($response);
?>