public function get($table, $hash, $range = null, Context\Get $context = null)
    {
        if (null !== $this->logger) {
            $this->log('Get on table '.$table);
        }

        // Primary key
        $hash = new Attribute($hash);

        $parameters = array(
            'TableName' => $table,
            'Key'       => array(
                'HashKeyElement' => $hash->getForDynamoDB()
            )
        );

        // Range key
        if (null !== $range) {
            $range = new Attribute($range);
            $parameters['Key']['RangeKeyElement'] = $range->getForDynamoDB();
        }

        if (null !== $context) {
            $parameters += $context->getForDynamoDB();
        }

        if (null !== $this->logger) {
            $this->log('Get request paramaters : '.print_r($parameters, true), Logger::DEBUG);
        }

        $response = $this->connector->getItem($parameters);

        if (null !== $this->logger) {
            $this->log('Get request response : '.print_r($response, true), Logger::DEBUG);
        }

        $this->addConsumedReadUnits($table, floatval($response['ConsumedCapacityUnits']));

        if (isset($response['Item'])) {
            $item = new Item($table);
            $item->populateFromDynamoDB($response['Item']);
            return $item;
        } else {
            if (null !== $this->logger) {
                $this->log('Didn\'t find item');
            }
            return null;
        }
    }
public function get($table, $hash, $range = null, Context\Get $context = null)
    {
        if (null !== $this->logger) {
            $this->log('Get on table '.$table);
        }

        // Primary key
        $hash = new Attribute($hash);

        $parameters = array(
            'TableName' => $table,
            'Key'       => array(
                'HashKeyElement' => $hash->getForDynamoDB()
            )
        );

        // Range key
        if (null !== $range) {
            $range = new Attribute($range);
            $parameters['Key']['RangeKeyElement'] = $range->getForDynamoDB();
        }

        if (null !== $context) {
            $parameters += $context->getForDynamoDB();
        }

        if (null !== $this->logger) {
            $this->log('Get request paramaters : '.print_r($parameters, true), Logger::DEBUG);
        }

        $response = $this->connector->getItem($parameters);

        if (null !== $this->logger) {
            $this->log('Get request response : '.print_r($response, true), Logger::DEBUG);
        }

        $this->addConsumedReadUnits($table, floatval($response['ConsumedCapacityUnits']));

        if (isset($response['Item'])) {
            $item = new Item($table);
            $item->populateFromDynamoDB($response['Item']);
            return $item;
        } else {
            if (null !== $this->logger) {
                $this->log('Didn\'t find item');
            }
            return null;
        }
    }
public function get ( $ table , $ hash , $ range = null , Context \ Get $ context = null ) { if ( null !== $ this -> logger ) { $ this -> log ( 'Get on table ' . $ table ) ; } // Primary key $ hash = new Attribute ( $ hash ) ; $ parameters = array ( 'TableName' => $ table , 'Key' => array ( 'HashKeyElement' => $ hash -> getForDynamoDB ( ) ) ) ; // Range key if ( null !== $ range ) { $ range = new Attribute ( $ range ) ; $ parameters [ 'Key' ] [ 'RangeKeyElement' ] = $ range -> getForDynamoDB ( ) ; } if ( null !== $ context ) { $ parameters += $ context -> getForDynamoDB ( ) ; } if ( null !== $ this -> logger ) { $ this -> log ( 'Get request paramaters : ' . print_r ( $ parameters , true ) , Logger :: DEBUG ) ; } $ response = $ this -> connector -> getItem ( $ parameters ) ; if ( null !== $ this -> logger ) { $ this -> log ( 'Get request response : ' . print_r ( $ response , true ) , Logger :: DEBUG ) ; } $ this -> addConsumedReadUnits ( $ table , floatval ( $ response [ 'ConsumedCapacityUnits' ] ) ) ; if ( isset ( $ response [ 'Item' ] ) ) { $ item = new Item ( $ table ) ; $ item -> populateFromDynamoDB ( $ response [ 'Item' ] ) ; return $ item ; } else { if ( null !== $ this -> logger ) { $ this -> log ( 'Didn\'t find item' ) ; } return null ; } }
Get an item via the get_item call
@param string $table The item table
@param mixed $hash The primary hash key
@param mixed|null $range The primary range key
@param Context\Get|null $context The call context
@return Item|null
Get an item via the get_item call