Database Reference
In-Depth Information
Using the AWS SDK for PHP
AWS has also given an SDK for PHP, with which you can perform table operations such as
create, update, delete, and list tables. Let's try to understand the implementation in greater
detail.
Create table
You can create a DynamoDB table in PHP by providing information, such as table name,
provision throughput settings, attributes, and primary key schema.
To invoke any table operation, first you need to create an instance of the DynamoDB client
and instantiate it with your AWS credentials, as shown in the following code:
$aws = Aws\Common\Aws::factory("./config.php");
$dynamodclient = $aws->get("dynamodb");
Once done, you can form create table request by providing
required details.
$tableName = "Book";
$result = $ dynamodclient ->createTable(array(
"TableName" => $tableName,
"AttributeDefinitions" => array(
array(
"AttributeName" => "bookId",
"AttributeType" => Type::NUMBER
)
),
"KeySchema" => array(
array(
"AttributeName" => "bookId",
"KeyType" => KeyType::HASH
)
),
"ProvisionedThroughput" => array(
"ReadCapacityUnits" => 10,
"WriteCapacityUnits" => 10
)
));
Search WWH ::




Custom Search