Database Reference
In-Depth Information
Using the AWS SDK for PHP
As we know AWS provides PHP APIs for table operations; we have the same for item op-
erations as well.
The putItem method
To add an item to a DynamoDB table, we can use the putItem method. The following is
an example of how to add a new book item to the Book table:
$response = $client->putItem(array(
"TableName" => "Book",
"Item" => array(
"bookId" => array( Type::NUMBER => 2001),
"name" => array( Type::STRING => "Dynamo DB"
),
"isbn" => array( Type::STRING =>
"978-233435-555" ),
"chapters" => array( Type::NUMBER => 10 ),
"authors" => array( Type::STRING_SET =>
array("XYZ", "PQR") )
)
));
The getItem method
We can retrieve the stored item in a DynamoDB table, as shown in the following code:
$response = $client->getItem(array(
"TableName" => "Book",
"Key" => array(
"bookId" => array( Type::NUMBER => 2001 )
)
));
Search WWH ::




Custom Search