我已经阅读了其他帖子,例如simpledb中的分页,但我有点不清楚为什么我的代码不起作用。我相信这个问题对于我看不到它的人来说是显而易见的。
//First I perform a count based on the suggestion in https://stackoverflow.com/questions/4623324/pagination-in-simpledb
$result = $client->select(array('SelectExpression' => "select count(*) from mydomain Where city='Dallas'"));
//I get back ~ 300 records when I check:$result['Items']['0']['Attributes']['0']['Value']
//Next I will query using count for the first 10 records so I can obtain the NextToken.
$result = $client->select(array('SelectExpression' => "select count(*) from mydomain Where city='Dallas' limit 10"));
//This works I see the 'NextToken'
$nexttoken = $result['NextToken'];
//Now I will fire off my final query this time I would like to use the NextToken
//My goal here is to pick up starting at record 11
$result = $client->select(array('SelectExpression' => "select * from mydomain Where city='Dallas' limit 10"),array('NextToken' => $nexttoken ));
查询成功,但我每次都会得到前 10 条记录。我期待记录 11-20
看起来NextToken被忽略了。
我确信这是愚蠢的事情,但我似乎无法让NextToken工作。
有什么想法我搞砸了吗?
谢谢
====
===================问题已解决,所以我想分享这个,以防其他人遇到这个问题。
使用适用于 PHP 的 AWS 开发工具包的 NextToken 时,您必须创建一个同时包含查询和下面的 NextToken 示例的数组。
$params = array('SelectExpression' => "select * from mydomain WHERE City ='Dallas' LIMIT 10");
$params['NextToken'] = $result['NextToken']; //Obtained from the count query we ran earlier
$result = $client->select($params);
祝你好运。
问题已解决,所以我想分享这个,以防其他人遇到这个问题。
使用适用于 PHP 的 AWS 开发工具包的 NextToken 时,您必须创建一个同时包含查询和下面的 NextToken 示例的数组。
$params = array('SelectExpression' => "select * from mydomain WHERE City ='Dallas' LIMIT 10");
$params['NextToken'] = $result['NextToken']; //Obtained from the count query we ran earlier
$result = $client->select($params);