コード例 #1
0
 /**
  * Executes a synchronous command.
  *
  * @param CommandInterface $command Command to execute.
  *
  * @return AwsDynamoDbResponse
  */
 protected function executeCommand(CommandInterface $command)
 {
     try {
         $result = $this->client->execute($command);
     } catch (AwsException $e) {
         /* Return an error response. */
         return new AwsDynamoDbResponse(null, $e);
     }
     return new AwsDynamoDbResponse($result, null);
 }
コード例 #2
0
 /**
  * @param string $pattern a pattern that table name should match, if emtpy, all tables will be returned
  *
  * @return array
  */
 public function listTables($pattern = '/.*/')
 {
     $tables = [];
     $lastEvaluatedTableName = null;
     do {
         $args = ["Limit" => 30];
         if ($lastEvaluatedTableName) {
             $args['ExclusiveStartTableName'] = $lastEvaluatedTableName;
         }
         $cmd = $this->db->getCommand('ListTables', $args);
         $result = $this->db->execute($cmd);
         if (isset($result['LastEvaluatedTableName'])) {
             $lastEvaluatedTableName = $result['LastEvaluatedTableName'];
         } else {
             $lastEvaluatedTableName = null;
         }
         foreach ($result['TableNames'] as $tableName) {
             if (preg_match($pattern, $tableName)) {
                 $tables[] = $tableName;
             }
         }
     } while ($lastEvaluatedTableName != null);
     return $tables;
 }