php - DynamoDB Query Iterator -


based on official dynamodb documentation, query operation retrieve maximum of 1mb of data, , recommended use getiterator method retrieve entire list of data matching query. sample code provided on http://docs.aws.amazon.com/aws-sdk-php/v2/guide/service-dynamodb.html#query below.

$iterator = $client->getiterator('query', array(     'tablename'     => 'errors',     'keyconditions' => array(         'id' => array(             'attributevaluelist' => array(                 array('n' => '1201')             ),             'comparisonoperator' => 'eq'         ),         'time' => array(             'attributevaluelist' => array(                 array('n' => strtotime("-15 minutes"))             ),             'comparisonoperator' => 'gt'         )     ) ));  // each item contain attributes added foreach ($iterator $item) {     // grab time number value     echo $item['time']['n'] . "\n";     // grab error string value     echo $item['error']['s'] . "\n"; } 

however, collate results in 1 json object , return response after iterations have completed. attempted use try block on foreach loop in code below. there's error message says "localhost unable handle request" error code of 500.

is there wrong way i'm handling promises (are considered promises?)? or purely because dataset large , connection timed out? deliberately commented out connect_timeout parameter when instantiated dynamodbclient still doesn't allow me fetch more data... advice on how can around this?

$results = array(); try {     foreach($iterator $item){         array_push($results, $item);     }     return response()->json($results); } catch (awsexception $e) {     return response()->json($e); } 


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -