/** * Select Action Sample * The Select operation returns a set of item names and associate attributes that match the * query expression. Select operations that run longer than 5 seconds will likely time-out * and return a time-out error response. * @param Amazon_SimpleDB_Interface $service instance of Amazon_SimpleDB_Interface * @param mixed $request Amazon_SimpleDB_Model_Select or array of parameters */ function invokeSelect(Amazon_SimpleDB_Interface $service, $request) { try { $response = $service->select($request); echo "Service Response\n"; echo "=============================================================================\n"; echo " SelectResponse\n"; if ($response->isSetSelectResult()) { echo " SelectResult\n"; $selectResult = $response->getSelectResult(); $itemList = $selectResult->getItem(); foreach ($itemList as $item) { echo " Item\n"; if ($item->isSetName()) { echo " Name\n"; echo " " . $item->getName() . "\n"; } $attributeList = $item->getAttribute(); foreach ($attributeList as $attribute) { echo " Attribute\n"; if ($attribute->isSetName()) { echo " Name\n"; echo " " . $attribute->getName() . "\n"; } if ($attribute->isSetValue()) { echo " Value\n"; echo " " . $attribute->getValue() . "\n"; } } } if ($selectResult->isSetNextToken()) { echo " NextToken\n"; echo " " . $selectResult->getNextToken() . "\n"; } } if ($response->isSetResponseMetadata()) { echo " ResponseMetadata\n"; $responseMetadata = $response->getResponseMetadata(); if ($responseMetadata->isSetRequestId()) { echo " RequestId\n"; echo " " . $responseMetadata->getRequestId() . "\n"; } if ($responseMetadata->isSetBoxUsage()) { echo " BoxUsage\n"; echo " " . $responseMetadata->getBoxUsage() . "\n"; } } } catch (Amazon_SimpleDB_Exception $ex) { echo "Caught Exception: " . $ex->getMessage() . "\n"; echo "Response Status Code: " . $ex->getStatusCode() . "\n"; echo "Error Code: " . $ex->getErrorCode() . "\n"; echo "Error Type: " . $ex->getErrorType() . "\n"; echo "Request ID: " . $ex->getRequestId() . "\n"; echo "XML: " . $ex->getXML() . "\n"; } }