當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DynamoDbClient::batchWriteItem方法代碼示例

本文整理匯總了PHP中Aws\DynamoDb\DynamoDbClient::batchWriteItem方法的典型用法代碼示例。如果您正苦於以下問題:PHP DynamoDbClient::batchWriteItem方法的具體用法?PHP DynamoDbClient::batchWriteItem怎麽用?PHP DynamoDbClient::batchWriteItem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Aws\DynamoDb\DynamoDbClient的用法示例。


在下文中一共展示了DynamoDbClient::batchWriteItem方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: batchWrite

 /**
  * Put Items and delete Keys by batch
  * @param Context\BatchWrite $context
  * @return null|Context\BatchWrite Return a new BatchWrite context if some request were not processed
  * @throws Exception\AttributesException
  */
 public function batchWrite(Context\BatchWrite $context)
 {
     if (null !== $this->logger) {
         $this->log('BatchWrite');
     }
     if (0 === count($context)) {
         $message = "BatchWrite context doesn't contain anything to write";
         if (null !== $this->logger) {
             $this->log($message, Logger::ERROR);
         }
         throw new Exception\AttributesException($message);
     }
     $parameters = $context->getForDynamoDB();
     if (null !== $this->logger) {
         $this->log('BatchWrite request paramaters : ' . print_r($parameters, true), Logger::DEBUG);
     }
     $response = $this->connector->batchWriteItem($parameters);
     if (null !== $this->logger) {
         $this->log('BatchWrite request response : ' . print_r($response, true), Logger::DEBUG);
     }
     // UnprocessedKeys
     if (count((array) $response['UnprocessedItems'])) {
         $newContext = new Context\BatchWrite();
         foreach ($response['UnprocessedItems'] as $table => $tableParameters) {
             foreach ($tableParameters as $request) {
                 if (isset($request['DeleteRequest'])) {
                     $keys = $request['DeleteRequest']['Key'];
                     $newContext->addKeyToDelete($table, current($keys['HashKeyElement']), isset($keys['RangeKeyElement']) ? current($keys['RangeKeyElement']) : null);
                 } elseif (isset($request['PutRequest'])) {
                     $item = new Item($table);
                     $item->populateFromDynamoDB($request['PutRequest']['Item']);
                     $newContext->addItemToPut($item);
                 }
             }
         }
         if (null !== $this->logger) {
             $this->log('More unprocessed Items');
         }
     } else {
         $newContext = null;
     }
     // Write Unit
     foreach ($response['Responses'] as $table => $responseItems) {
         $this->addConsumedWriteUnits($table, floatval($responseItems['ConsumedCapacityUnits']));
     }
     return $newContext;
 }
開發者ID:16hands,項目名稱:riverline-dynamodb,代碼行數:53,代碼來源:Connection.php

示例2: batchWriteItem

 /**
  * Executes the BatchWriteItem operation.
  *
  * @param array  $requestItems                Associative array of <TableName> keys mapping to (array<associative-array>) values.
  * @param string $returnConsumedCapacity      Sets consumed capacity return mode.
  * @param string $returnItemCollectionMetrics If set to SIZE, statistics about item collections, if any, that were modified during the operation are returned in the response.
  *
  * @return Guzzle\Service\Resource\Model
  *
  * @see http://docs.aws.amazon.com/aws-sdk-php/latest/class-Aws.DynamoDb.DynamoDbClient.html#_batchWriteItem
  */
 public function batchWriteItem(array $requestItems, $returnConsumedCapacity = self::CAPACITY_NONE, $returnItemCollectionMetrics = self::METRICS_NONE)
 {
     return $this->client->batchWriteItem(['RequestItems' => $requestItems, 'ReturnConsumedCapacity' => $returnConsumedCapacity, 'ReturnItemCollectionMetrics' => $returnItemCollectionMetrics]);
 }
開發者ID:m6web,項目名稱:aws-bundle,代碼行數:15,代碼來源:Client.php


注:本文中的Aws\DynamoDb\DynamoDbClient::batchWriteItem方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。