Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php使用列表从DynamoDB表中获取项目_Php_Amazon Web Services_Amazon Dynamodb - Fatal编程技术网

php使用列表从DynamoDB表中获取项目

php使用列表从DynamoDB表中获取项目,php,amazon-web-services,amazon-dynamodb,Php,Amazon Web Services,Amazon Dynamodb,我有一个用户名数组,我想从DynamoDB表中检索包含该数组中存在的用户名的所有项 例如:如果我的数组是: [“Foo”,“Bar”] 我的桌子是: 用户名|属性1 |属性2 Foo |值1 |值2 最小值|值1 |值2 条形图|值1 |值2 然后我想得到第一项和最后一项 我阅读了scan操作的文档,但它似乎不支持这种类型的请求 我所要求的是可能的还是必须迭代我的用户名数组并分别检索每个用户名的项?您可能需要使用if用户名作为表的哈希键 Batch Get Item API允许您基于Dy

我有一个用户名数组,我想从DynamoDB表中检索包含该数组中存在的用户名的所有项

例如:如果我的数组是:


[“Foo”,“Bar”]

我的桌子是:


用户名|属性1 |属性2
Foo |值1 |值2
最小值|值1 |值2
条形图|值1 |值2

然后我想得到第一项和最后一项

我阅读了
scan
操作的文档,但它似乎不支持这种类型的请求

我所要求的是可能的还是必须迭代我的用户名数组并分别检索每个用户名的项?

您可能需要使用if用户名作为表的哈希键


Batch Get Item API允许您基于DynamoDB表检索多个项,前提是您在请求中提供的键是HashKey(+RangeKey)或全局二级索引(HashKey(+RangeKey))的一部分。以下是Batch Get示例。请注意,您可能需要执行批处理API,直到UnprocessedKeys为null


username是表的散列键?@nometerquest YesCan你能给我举个例子说明怎么做吗?用户名是我的哈希键,但没有范围键。
var params = {
    "RequestItems" : {
        "yourtablename" : {
            "Keys" : [ {
                "username" : "Foo"              
            },{
                "username" : "Bar"              
            } ],
        }
    },
    "ReturnConsumedCapacity" : "TOTAL"
};

docClient.batchGet(params, function(err, data) {
    if (err) {
        console.error("Unable to read item. Error JSON:", JSON.stringify(err,
                null, 2));
    } else {
        console.log("GetItem succeeded:", JSON.stringify(data, null, 2));
    }
});