hi there - i don't see anywhere in this library where the token is returned on either select or query…. so that you can then use the token for the next request (for paging through a dataset). am i just missing it?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, just wondering what the status of this is. I've modified your class to make this work, but it would be nice to have an official release (with the newer API spec too)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yeah, sorry about the delay. The other dev has made all the updates, including updating to the new API spec and some other things, he's just making a few more changes before it's ready.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2010-02-13
oops, i selected "Codeify" on the above snippet, but it didn't work. Trying again here:
<pre>
/**
* Evaluate a select expression on a domain
*
* Function provided by Matthew Lanham
*
* @param string $domain The domain being queried
* @param string $select The select expression to evaluate.
* @param string $nexttoken The token to start from when retrieving results
* @return array | false
*/
public static function select($domain, $select, $nexttoken = null, $includeNextToken = null) {
$rest = new SimpleDBRequest($domain, 'Select', 'GET', self::$__accessKey);
hi there - i don't see anywhere in this library where the token is returned on either select or query…. so that you can then use the token for the next request (for paging through a dataset). am i just missing it?
I don't think you're missing it. Glancing at the code, it looks like I forgot to include the "NextToken" response in the result.
I actually need to update the library to use the newer 2009-04-15 API spec; it's using the older 2007-11-07 spec right now.
I'll update it this week and post the new code this weekend.
Hi, just wondering what the status of this is. I've modified your class to make this work, but it would be nice to have an official release (with the newer API spec too)
Yeah, sorry about the delay. The other dev has made all the updates, including updating to the new API spec and some other things, he's just making a few more changes before it's ready.
Here's our change to the select method to get token:
oops, i selected "Codeify" on the above snippet, but it didn't work. Trying again here:
<pre>
/**
* Evaluate a select expression on a domain
*
* Function provided by Matthew Lanham
*
* @param string $domain The domain being queried
* @param string $select The select expression to evaluate.
* @param string $nexttoken The token to start from when retrieving results
* @return array | false
*/
public static function select($domain, $select, $nexttoken = null, $includeNextToken = null) {
$rest = new SimpleDBRequest($domain, 'Select', 'GET', self::$__accessKey);
if($select != '')
{
$rest->setParameter('SelectExpression', $select);
}
if($nexttoken !== null)
{
$rest->setParameter('NextToken', $nexttoken);
}
$rest = $rest->getResponse();
if ($rest->error === false && $rest->code !== 200)
$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
if ($rest->error !== false) {
SimpleDB::__triggerError('query', $rest->error);
return false;
}
$results = array();
//Zend_Debug::dump($rest->body->SelectResult, '$rest->body->SelectResult');die();
if (!isset($rest->body->SelectResult))
{
return $results;
}
if ($includeNextToken) {
// !! IMPORTANT !! ADD NEXT TOKEN VALUE INTO SEARCH RESULTS
if (isset($rest->body->SelectResult->NextToken)) {
$results = strval($rest->body->SelectResult->NextToken);
}
}
foreach($rest->body->SelectResult->Item as $i)
{
$item = array('Name' => (string)($i->Name), 'Attributes' => array());
foreach($i->Attribute as $a)
{
if(isset($item))
{
$temp = (array)($item);
$temp = (string)($a->Value);
$item = $temp;
}
else
{
$item = (string)($a->Value);
}
}
$results = $item;
}
return $results;
}
</pre>
when is the new library gonna be released ?
btw.. did I ever mention that u guys rock….. official library provided by Amazon sucks.. this library saved my day
Thanks, I'm glad you like it :)
A new version was uploaded today, it should have all the features you guys need.