Esempio n. 1
0
 /**
  * @param string $tableName
  * @param array $values
  */
 public function putItem($tableName, $values)
 {
     $marshaler = new Marshaler();
     $command = $this->getClient()->getCommand('PutItem', ['TableName' => $tableName, 'Item' => $marshaler->marshalItem($values)]);
     $marshaler->marshalItem($values);
     try {
         $this->getClient()->execute($command);
         return true;
     } catch (\Exception $exc) {
         return false;
     }
 }
Esempio n. 2
0
 /**
  * Builds a DynamoDB command to put multiple items.
  *
  * @param string $table   The name of the table to be created.
  * @param array  $values  The value to put into the table.
  * @param array  $options The value to put into the table.
  * @return array The create table request syntax. The first element is the name of the command,
  * the second is the argument.
  */
 public function batchPutItem($table, array $values, array $options = [])
 {
     $name = 'BatchWriteItem';
     $requests = array_map(function ($value) {
         return ['PutRequest' => ['Item' => Marshaler::marshalItem($value)]];
     }, $values);
     $argument = array_merge(['RequestItems' => [$table => $requests]], $options);
     return [$name, $argument];
 }