Created
June 12, 2012 11:35
-
-
Save mk0y/2917015 to your computer and use it in GitHub Desktop.
DynamoDB example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_once dirname(__FILE__) . '/sdk-1.5.6.2/sdk.class.php'; | |
$dynamodb = new AmazonDynamoDB(); | |
// set closest region | |
$dynamodb->set_hostname("http://dynamodb.eu-west-1.amazonaws.com"); | |
// Name for your table | |
$table_name = "ObjectsTest"; | |
// This is how they suggest to initialize the table | |
do { | |
sleep(1); | |
$response = $dynamodb->describe_table(array( | |
'TableName' => $table_name | |
)); | |
} | |
while ((string) $response->body->Table->TableStatus !== 'ACTIVE'); | |
// Creating the table with attributes | |
$response = $dynamodb->create_table(array( | |
'TableName' => $table_name, | |
'KeySchema' => array( | |
'HashKeyElement' => array( | |
'AttributeName' => 'Id', | |
'AttributeType' => AmazonDynamoDB::TYPE_NUMBER | |
) | |
), | |
'ProvisionedThroughput' => array( | |
'ReadCapacityUnits' => 10, | |
'WriteCapacityUnits' => 5 | |
) | |
)); | |
if ($response->isOK()){ | |
ok... | |
} else { | |
not ok... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment