我在PHP中使用DynamoDb,但我无法更新我的项目(字符串集)。
$friends_list = array();
array_push( $friends_list, "user1" );
$response = $client->updateItem(array(
'TableName' => 'myTable',
'Key' => array(
'id' => array(Type::STRING => $userid),
'username' => array(Type::STRING => $username)
),
'AttributeUpdates' => array(
'friends_list' => array(
'Value' => array(Type::STRING_SET => $friends_list),
'Action' => AttributeAction::PUT)
),
'ReturnValues' => 'ALL_NEW'
));
我收到错误消息:
PHP Fatal error: Uncaught Aws\DynamoDb\Exception\DynamoDbException: AWS Error Code: SerializationException, Status Code: 400, AWS Request ID: EG1EUDVTNPRST9DAA94NQP592BVV4KQNSO5AEMVJF66Q9ASUAAJG, AWS Error Type: client, AWS Error Message: class java.lang.Short can not be converted to an String, User-Agent: aws-sdk-php2/2.7.5 Guzzle/3.9.2 curl/7.35.0 PHP/5.5.9-1ubuntu4.5
thrown in /var/www/html/aws-sdk-php-master/src/Aws/Common/Exception/NamespaceExceptionFactory.php on line 91
为什么?
$ friends_list是数组,但无法使用StringSet更新。
这段代码没有错误:
'Value' => array(Type::STRING_SET => array("user1")),
但是,此代码会收到错误消息:
'Value' => array(Type::STRING_SET => $friends_list),
我无法理解。