/** * Create a table * * @param mixed $schema */ function createTable($schema = null) { if ($schema == null) { $schema = $this->schema; } $this->response = $this->dynamodb->create_table($schema); // Sleep and poll until it's created do { sleep(1); $this->describeTable(); } while ((string) $this->response->body->Table->TableStatus !== 'ACTIVE'); return true; }
function create_table() { // Instantiate the class. $dynamodb = new AmazonDynamoDB(); $response = $dynamodb->create_table(array('TableName' => $this->tableName, 'KeySchema' => array('HashKeyElement' => array('AttributeName' => $this->primaryKey, 'AttributeType' => AmazonDynamoDB::TYPE_NUMBER)), 'ProvisionedThroughput' => array('ReadCapacityUnits' => 5, 'WriteCapacityUnits' => 5))); // Check for success... if ($response->isOK()) { // continue } else { echo '# A ERROR HAS OCCURED<br />'; print_r($response); return false; } #################################################################### # Sleep and poll until the table has been created $count = 0; do { sleep(1); $count++; $response = $dynamodb->describe_table(array('TableName' => $this->tableName)); } while ((string) $response->body->Table->TableStatus !== 'ACTIVE'); return true; }