当前位置: 首页>>代码示例>>PHP>>正文


PHP DynamoDbClient::query方法代码示例

本文整理汇总了PHP中Aws\DynamoDb\DynamoDbClient::query方法的典型用法代码示例。如果您正苦于以下问题:PHP DynamoDbClient::query方法的具体用法?PHP DynamoDbClient::query怎么用?PHP DynamoDbClient::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Aws\DynamoDb\DynamoDbClient的用法示例。


在下文中一共展示了DynamoDbClient::query方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getActionByUniquenessKey

 public function getActionByUniquenessKey($user_id, $uniqueness_key)
 {
     $response = $this->client->query(['TableName' => 'tr_actions', 'IndexName' => 'uniqueness_key-index', 'KeyConditionExpression' => 'user_id = :user_id AND uniqueness_key = :u_key', 'ExpressionAttributeValues' => [':user_id' => ['S' => $user_id], ':u_key' => ['S' => $uniqueness_key]], 'Limit' => 1]);
     if (!empty($response['Items'])) {
         $action = new \App\Action();
         $action->fromArray($this->marshaler->unmarshalItem($response['Items'][0]));
         return $action;
     }
     return null;
 }
开发者ID:jacksteadman,项目名称:tracer2,代码行数:10,代码来源:DynamoDb.php

示例2: query

 /**
  * query
  *
  * @param  array $conditions
  * @param  array $options
  *
  * @return array
  *
  * @link http://docs.aws.amazon.com/aws-sdk-php/latest/class-Aws.DynamoDb.DynamoDbClient.html#_query
  */
 public function query(array $conditions, array $options = array())
 {
     $args = array('TableName' => $this->_table_name, 'KeyConditions' => $conditions, 'ScanIndexForward' => true, 'Select' => 'ALL_ATTRIBUTES', 'ReturnConsumedCapacity' => 'TOTAL', 'ConsistentRead' => $this->_consistent_read);
     // Merge $options to $args
     $option_names = array('ScanIndexForward', 'QueryFilter');
     foreach ($option_names as $option_name) {
         if (isset($options[$option_name])) {
             $args[$option_name] = $options[$option_name];
         }
     }
     // if IndexName is specified
     if ($this->_query_index_name) {
         $args['IndexName'] = $this->_query_index_name;
     }
     if (intval($this->_limit) > 0) {
         // Has limit
         // if ExclusiveStartKey is set
         if ($this->_exclusive_start_key) {
             $exclusive_start_key = $this->_formatAttributes($this->_exclusive_start_key);
             $args['ExclusiveStartKey'] = $exclusive_start_key;
         }
         $args['Limit'] = intval($this->_limit);
         $result = self::$_client->query($args);
         self::_logQuery("query", $args, $result);
         // $result is "Guzzle\Service\Resource\Model"
         // and $result has next keys
         // - Count
         // - Items
         // - ScannedCount
         // - LastEvaluatedKey
         $items = $result['Items'];
         // Set LastEvaluatedKey
         $last_evaluated_key = null;
         if (isset($result['LastEvaluatedKey'])) {
             $last_evaluated_key = $this->_formatResult($result['LastEvaluatedKey']);
         }
         $this->_last_evaluated_key = $last_evaluated_key;
         // Set Count
         $result_count = null;
         if (isset($result['Count'])) {
             $result_count = $result['Count'];
         }
         $this->_result_count = $result_count;
     } else {
         // No limit (Use Iterator)
         $iterator = self::$_client->getIterator('Query', $args);
         self::_logQuery('getIterator', $args, $iterator);
         // $iterator is "Aws\Common\Iterator\AwsResourceIterator"
         $items = array();
         foreach ($iterator as $item) {
             $items[] = $item;
         }
         // Set Count
         $this->_result_count = count($items);
     }
     return $this->_formatResults($items);
 }
开发者ID:albertleao,项目名称:kettle,代码行数:67,代码来源:kettle.php

示例3: query

 /**
  * Get items via the query call
  * @param string $table The item table
  * @param mixed $hash The primary hash key
  * @param Context\Query|null $context The call context
  * @return Collection
  */
 public function query($table, $hash, Context\Query $context = null)
 {
     if (null !== $this->logger) {
         $this->log('Query on table ' . $table);
     }
     $hash = new Attribute($hash);
     $parameters = array('TableName' => $table, 'HashKeyValue' => $hash->getForDynamoDB());
     if (null !== $context) {
         $parameters += $context->getForDynamoDB();
     }
     if (null !== $this->logger) {
         $this->log('Query request paramaters : ' . print_r($parameters, true), Logger::DEBUG);
     }
     $response = $this->connector->query($parameters);
     if (null !== $this->logger) {
         $this->log('Query request response : ' . print_r($response, true), Logger::DEBUG);
     }
     $this->addConsumedReadUnits($table, floatval($response['ConsumedCapacityUnits']));
     if (isset($response['LastEvaluatedKey'])) {
         if (null === $context) {
             $nextContext = new Context\Query();
         } else {
             $nextContext = clone $context;
         }
         $nextContext->setExclusiveStartKey($response['LastEvaluatedKey']);
         if (null !== $this->logger) {
             $this->log('More Items to retrieve');
         }
     } else {
         $nextContext = null;
     }
     $items = new Collection($nextContext, $response['Count']);
     if (!empty($response['Items'])) {
         foreach ($response['Items'] as $responseItem) {
             $item = new Item($table);
             $item->populateFromDynamoDB($responseItem);
             $items->add($item);
         }
     }
     if (null !== $this->logger) {
         $this->log('Find ' . count($items) . ' Items');
     }
     return $items;
 }
开发者ID:16hands,项目名称:riverline-dynamodb,代码行数:51,代码来源:Connection.php

示例4: query

 /**
  * Executes the Query operation.
  *
  * @param string $tableName The name of the table containing the requested items.
  * @param array  $args      Arguments of the query
  *
  * @return  Guzzle\Service\Resource\Model
  *
  * @see http://docs.aws.amazon.com/aws-sdk-php/latest/class-Aws.DynamoDb.DynamoDbClient.html#_query
  */
 public function query($tableName, array $args)
 {
     $args['TableName'] = $tableName;
     return $this->client->query($args);
 }
开发者ID:m6web,项目名称:aws-bundle,代码行数:15,代码来源:Client.php


注:本文中的Aws\DynamoDb\DynamoDbClient::query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。