<bdo id='4IWTq'></bdo><ul id='4IWTq'></ul>
  • <legend id='4IWTq'><style id='4IWTq'><dir id='4IWTq'><q id='4IWTq'></q></dir></style></legend>

      <tfoot id='4IWTq'></tfoot>

        <small id='4IWTq'></small><noframes id='4IWTq'>

        <i id='4IWTq'><tr id='4IWTq'><dt id='4IWTq'><q id='4IWTq'><span id='4IWTq'><b id='4IWTq'><form id='4IWTq'><ins id='4IWTq'></ins><ul id='4IWTq'></ul><sub id='4IWTq'></sub></form><legend id='4IWTq'></legend><bdo id='4IWTq'><pre id='4IWTq'><center id='4IWTq'></center></pre></bdo></b><th id='4IWTq'></th></span></q></dt></tr></i><div id='4IWTq'><tfoot id='4IWTq'></tfoot><dl id='4IWTq'><fieldset id='4IWTq'></fieldset></dl></div>

        使用多个嵌套 JSON 键 (PHP) 进行 DynamoDB 扫描

        时间:2024-05-10
          <tbody id='f0kbT'></tbody>
      1. <tfoot id='f0kbT'></tfoot>
        1. <i id='f0kbT'><tr id='f0kbT'><dt id='f0kbT'><q id='f0kbT'><span id='f0kbT'><b id='f0kbT'><form id='f0kbT'><ins id='f0kbT'></ins><ul id='f0kbT'></ul><sub id='f0kbT'></sub></form><legend id='f0kbT'></legend><bdo id='f0kbT'><pre id='f0kbT'><center id='f0kbT'></center></pre></bdo></b><th id='f0kbT'></th></span></q></dt></tr></i><div id='f0kbT'><tfoot id='f0kbT'></tfoot><dl id='f0kbT'><fieldset id='f0kbT'></fieldset></dl></div>

              • <bdo id='f0kbT'></bdo><ul id='f0kbT'></ul>

                  <small id='f0kbT'></small><noframes id='f0kbT'>

                  <legend id='f0kbT'><style id='f0kbT'><dir id='f0kbT'><q id='f0kbT'></q></dir></style></legend>
                  本文介绍了使用多个嵌套 JSON 键 (PHP) 进行 DynamoDB 扫描的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的数据存储在 DynamoDB 中的单个表events"中,采用以下架构,_id"作为哈希键,microtime"作为范围键(以下示例数据):

                  My data is stored in a single table "events" in DynamoDB in the following schema with "_id" as hash key and "microtime" as range key (example data below):

                  {
                    "_id": {
                      "S": "ae3761b5-b73b-4fb9-ae5a-5cc230b8fa11"
                    },
                    "data": {
                      "M": {
                        "name": {
                          "S": "Jeff"
                        },
                        "purchase_value": {
                          "N": "25"
                        },
                        "user_id": {
                          "N": "1201"
                        }
                      }
                    },
                    "microtime": {
                      "N": "14147568808639"
                    }
                  }
                  

                  我正在使用 AWS PHP SDK 2.7.0 根据我的过滤器(在本例中为主哈希键_id")扫描数据库.我下面的代码完美运行(返回正确的条目):

                  I am using AWS PHP SDK 2.7.0 to scan the database based on my filters (in this example, primary hash key "_id"). My code below that works perfectly (returns correct entry):

                  $client = DynamoDbClient::factory(array(
                                  'key'    => 'key',
                                  'secret' => 'secret',
                                  'region' => 'eu-west-1'
                  ));
                  
                  $iterator = $client->getIterator('Scan', array(
                      'TableName' => 'events',
                      'ScanFilter' => array(
                          '_id' => array(
                              'AttributeValueList' => array(
                                  array('S' => "ae3761b5-b73b-4fb9-ae5a-5cc230b8fa11")
                              ),
                              'ComparisonOperator' => 'EQ'
                          ),
                      )
                  ));
                  
                  foreach ($iterator as $item) {
                    print_r($item);
                  }
                  

                  现在,当我尝试根据数据"元素内部的数据进行扫描时,我无法获得任何匹配的条目.下面的示例代码(我正在尝试使用 data.name=Jeff 提取所有内容):

                  now when I try to scan based on data INSIDE of the "data" element, I can't get any matching entries. Example code below (I am trying to extract all with data.name=Jeff):

                  $iterator = $client->getIterator('Scan', array(
                      'TableName' => 'events',
                      'ScanFilter' => array(
                          'data.name' => array(
                              'AttributeValueList' => array(
                                  array('S' => "Jeff")
                              ),
                              'ComparisonOperator' => 'EQ'
                          ),
                      )
                  ));
                  
                  foreach ($iterator as $item) {
                    print_r($item);
                  }
                  

                  任何人都可以看到我的代码有任何问题,或者实际上无法通过比较 JSON 文档内部的值来提取数据?提前感谢您的任何建议!

                  Anyone can see any issues with my code, or is it in fact not possible to extract data by comparing values INSIDE of a JSON document? Thanks in advance for any suggestions!

                  编辑

                  我已尝试使用 DynamoDB PHP SDK 文档中的以下代码 (http://docs.aws.amazon.com/aws-sdk-php/v3/api/Aws/DynamoDb/dynamodb-2012-08-10.html#scan) - 仍然没有成功.我只能在使用主哈希/范围键和任何其他(一级")键进行扫描时检索,但不能像我的示例中那样使用来自文档(地图/列表)内部的键.见下文:

                  I've tried the following code from DynamoDB PHP SDK Documentation (http://docs.aws.amazon.com/aws-sdk-php/v3/api/Aws/DynamoDb/dynamodb-2012-08-10.html#scan) - still no success. I can only retrieve when scanning using primary hash/range key, and any other ("first-level") key, but not using a key from INSIDE of a document (map/list) like in my example. See below:

                  $iterator = $client->getIterator('Scan', array(
                      'TableName' => 'events',
                      'ScanFilter' => array(
                          'data' => array(
                              'AttributeValueList' => array(
                                  array(
                                      'M' => array(
                                          'name' => array("S"=>"Jeff"),
                                      ),
                                  ),
                              ),
                              'ComparisonOperator' => 'EQ',
                          ),
                      ),
                  ));
                  

                  推荐答案

                  解决我的问题:

                  $iterator = $client->getIterator('Scan', array(
                      'TableName' => 'event_test2',
                      'FilterExpression' => 'event.customer_name = :filter',
                      "ExpressionAttributeValues" => array(":filter"=>array("S"=>"Jeff")),
                  ));
                  

                  更多信息在这里:https://forums.aws.amazon.com/thread.jspa?threadID=164470

                  这篇关于使用多个嵌套 JSON 键 (PHP) 进行 DynamoDB 扫描的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:使用 PHP AWS SDK 在 DynamoDB 中存储 JSON 文档 下一篇:使用 .getJSON 获取 Play 商店应用详细信息时出现跨域阻止请求 [CORS] 错误

                  相关文章

                • <small id='XvAKD'></small><noframes id='XvAKD'>

                  1. <tfoot id='XvAKD'></tfoot>
                    <legend id='XvAKD'><style id='XvAKD'><dir id='XvAKD'><q id='XvAKD'></q></dir></style></legend>
                    1. <i id='XvAKD'><tr id='XvAKD'><dt id='XvAKD'><q id='XvAKD'><span id='XvAKD'><b id='XvAKD'><form id='XvAKD'><ins id='XvAKD'></ins><ul id='XvAKD'></ul><sub id='XvAKD'></sub></form><legend id='XvAKD'></legend><bdo id='XvAKD'><pre id='XvAKD'><center id='XvAKD'></center></pre></bdo></b><th id='XvAKD'></th></span></q></dt></tr></i><div id='XvAKD'><tfoot id='XvAKD'></tfoot><dl id='XvAKD'><fieldset id='XvAKD'></fieldset></dl></div>
                        <bdo id='XvAKD'></bdo><ul id='XvAKD'></ul>