Reputation: 1359
I have the following code to place an item in a table in dynamoDb it works fine. I want to nest an array in an array. For example, for the attribute 'color1' I want to make "A" to be array of items. How can I do that
$result = $client->putItem(array(
'TableName' => 'usr',
'Item' => array(
'email' => array('S'=>$_POST['email']),
'first' => array('S'=>$_POST['firstname']),
'country' => array('S'=>$_POST['country']),
'last' => array('S'=>$_POST['lastname']),
'password' => array('S'=>$hashedpassword),
'list'=> array('SS'=> array("1", "2", "3")),
'color1'=> array('SS'=> array("A", "2", "5")),
'phonenumber' =>array('S'=>$_POST['phonenumber']))
));
Upvotes: 1
Views: 109
Reputation: 42384
The exact same way you're doing it for the outer SS
array; with mapping:
$result = $client->putItem(array(
'TableName' => 'usr',
'Item' => array(
'email' => array('S' => $_POST['email']),
'first' => array('S' => $_POST['firstname']),
'country' => array('S' => $_POST['country']),
'last' => array('S' => $_POST['lastname']),
'password' => array('S' => $hashedpassword),
'list' => array('SS '=> array("1", "2", "3")),
'color1' => array('SS' => array("A" => array('1', '2'), "2", "5")),
'phonenumber' => array('S' => $_POST['phonenumber'])
)
));
Upvotes: 1