dongxie3963
2017-07-25 13:24
浏览 68
已采纳

使用PHP扫描DynamoDB表以获取当月的结果

I have a table in AWS DynamoDB, and every item in this table has a String-type "date" attribute, which contains the date when the specific item was created. The date in this attribute is being saved in this format: dd/mm/YYYY.

What I want to do is to scan this table, and get all of the results from the current month. I also want to do 2 more individual scans. One for results from the last month (for example, now it is July, so I want to get results from June), and from 2 months ago (for example, I want to get all the results from May).

In the DynamoDB PHP SDK documentation, they are demonstrating a scan, and in the example they are filtering the scan according to an attribute called "time" using this code:

'time' => array(
    'AttributeValueList' => array(
        array('N' => strtotime('-15 minutes'))
    ),
    'ComparisonOperator' => 'GT'
)

So I thought that I could replace -15 minutes with -1 month, but the problem with it is that, as you can see in the code above, the "time" attribute is a Number-type, and not String-type, so I can't perform this action.

What can I do to get results only from the current month?

图片转代码服务由CSDN问答提供 功能建议

我在AWS DynamoDB中有一个表,该表中的每个项都有一个String类型的“date”属性, 其中包含创建特定项目的日期。 此属性中的日期将以以下格式保存: dd / mm / YYYY

我要做的是扫描此表,并获取所有 当月的结果。 我还想再进行2次单独扫描。 一个是上个月的结果(例如,现在是7月,所以我想从6月获得结果),从2个月前开始(例如,我希望从5月获得所有结果)。

在DynamoDB PHP SDK文档中,他们演示了扫描,在示例中,他们使用此代码根据名为“time”的属性过滤扫描: < pre> 'time'=&gt; 数组( 'AttributeValueList'=&gt;数组( 数组('N'=&gt; strtotime(' - 15分钟')) ), 'ComparativeOperator'=&gt;'GT' )\ n

所以我认为我可以用 -1 month 替换 -15分钟,但问题是什么 就像你在上面的代码中看到的那样,“time”属性是Number-type,而不是String-type,所以我不能执行这个动作。

什么 我是否可以仅从当月获得结果?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题