gpt4 book ai didi

php - DynamoDB 与 PHP,update_item 错误

转载 作者:搜寻专家 更新时间:2023-10-31 22:12:51 26 4
gpt4 key购买 nike

我正在尝试使用 PHP SDK 更新我的 DynamoDB 表中的表。这是错误:

com.amazon.coral.service#SerializationException在不希望的地方找到列表的开始

我猜我的数组格式有问题。我正在使用这个 documentation以供引用。

我发送的数组:

array(3) {
["TableName"]=>
string(7) "teacher"
["Key"]=>
array(1) {
["HashKeyElement"]=>
array(1) {
["S"]=>
string(36) "97770A6A-EF06-AF4A-3E30-87DAC0237F6D"
}
}
["AttributeUpdates"]=>
array(1) {
[0]=>
array(2) {
["population"]=>
array(1) {
["Action"]=>
string(3) "ADD"
}
["Value"]=>
array(1) {
["SS"]=>
array(1) {
[0]=>
string(36) "97770A6A-EF06-AF4A-3E30-87DAC0237F6D"
}
}
}
}
}

最佳答案

AttributeUpdates 中的“人口”在数组中的位置不正确。它应该是元素的键而不是元素本身。 “Value”和“Action”都是数组元素的一部分:结构应该是:

array(3) {
["TableName"]=>
string(7) "teacher"
["Key"]=>
array(1) {
["HashKeyElement"]=>
array(1) {
["S"]=>
string(36) "97770A6A-EF06-AF4A-3E30-87DAC0237F6D"
}
}
["AttributeUpdates"]=>
array(1) {
["population"]=>
array(1) {
["Value"]=>
array(2) {
["SS"]=>
array(1) {
[0]=>
string(36) "97770A6A-EF06-AF4A-3E30-87DAC0237F6D"
}
["Action"]=>
string(3) "ADD"
}
}
}
}

来源:

$updateOptions = array(
'TableName' => 'teacher',
'Key' => array(
'HashKeyElement' => array('S' => '97770A6A-EF06-AF4A-3E30-87DAC0237F6D'),
),
'AttributeUpdates' => array(
'population' => array('Value' => array('SS' => array('97770A6A-EF06-AF4A-3E30-87DAC0237F6D'), 'Action' => 'ADD')),
)
);

关于php - DynamoDB 与 PHP,update_item 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10660621/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com