The Select
operation returns a set of attributes for ItemNames
that
match the select expression. Select
is similar to the standard SQL SELECT
statement.
The total size of the response cannot exceed 1 MB in total size. Amazon SimpleDB automatically
adjusts the number of items returned per page to enforce this limit. For example, if the client
asks to retrieve 2500 items, but each individual item is 10 kB in size, the system returns 100
items and an appropriate NextToken
so the client can access the next page of
results.
For information on how to construct select expressions, see Using Select to Create Amazon SimpleDB Queries in the Developer Guide.
Access
public
Parameters
Parameter |
Type |
Required |
Description |
---|---|---|---|
|
Required |
The expression used to query the domain. |
|
|
Optional |
An associative array of parameters that can have the following keys:
|
Returns
Type |
Description |
---|---|
A |
Examples
Select data from a SimpleDB domain.
// Instantiate $sdb = new AmazonSDB(); $response = $sdb->select('SELECT * FROM `example-domain`'); // Success? var_dump($response->isOK());Result:
bool(true)
Select more data by passing a NextToken parameter.
The best way to collect more data is to continue to loop until there are no more NextToken
values remaining. Here, we use a do-while loop.
// Instantiate $sdb = new AmazonSDB(); $select_expression = 'SELECT * FROM `example-domain`'; $next_token = null; do { if ($next_token) { $response = $sdb->select($select_expression, array( 'NextToken' => $next_token, )); } else { $response = $sdb->select($select_expression); } // ...Store data! $next_token = isset($response->body->SelectResult->NextToken) ? (string) $response->body->SelectResult->NextToken : null; } while ($next_token); echo '.';
Related Methods
Source
Method defined in services/sdb.class.php | Toggle source view (7 lines) | View on GitHub