I'm new to dynamoDB and am struggling to populate my DynamoDB table which I have defined the table as follows:
$response = $DynamoDb->createTable([ 'TableName' => 'products', 'AttributeDefinitions' => [ [ 'AttributeName' => 'product_code', 'AttributeType' => 'N' ], [ 'AttributeName' => 'created_at', 'AttributeType' => 'N' ], ], 'KeySchema' => [ [ 'AttributeName' => 'product_code', 'KeyType' => 'HASH' ], [ 'AttributeName' => 'created_at', 'KeyType' => 'RANGE' ] ], 'ProvisionedThroughput' => [ 'ReadCapacityUnits' => 5, 'WriteCapacityUnits' => 6 ] ]);
and populated using
$result = $DynamoDb->putItem([ 'TableName' => 'products', 'Item' => [ 'product_code' => ['N' => (int)$row[0]], 'created_at' => ['N' => (int)strtotime("now")] ] ]);
I keep getting the error
Integer can not be converted to an String
Can anybody please advise a newbie. Many thanks.