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

        $parameters = array(
            'TableName' => $table
        );

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

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

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

        if (null !== $this->logger) {
            $this->log('Scan request response : '.print_r($response, true), Logger::DEBUG);
            $this->log($response['ScannedCount'].' scanned items');
        }

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

        if (isset($response['LastEvaluatedKey'])) {
            if (null === $context) {
                $nextContext = new Context\Scan();
            } 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;
    }
public function scan($table, Context\Scan $context = null)
    {
        if (null !== $this->logger) {
            $this->log('Scan on table '.$table);
        }

        $parameters = array(
            'TableName' => $table
        );

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

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

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

        if (null !== $this->logger) {
            $this->log('Scan request response : '.print_r($response, true), Logger::DEBUG);
            $this->log($response['ScannedCount'].' scanned items');
        }

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

        if (isset($response['LastEvaluatedKey'])) {
            if (null === $context) {
                $nextContext = new Context\Scan();
            } 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;
    }
public function scan ( $ table , Context \ Scan $ context = null ) { if ( null !== $ this -> logger ) { $ this -> log ( 'Scan on table ' . $ table ) ; } $ parameters = array ( 'TableName' => $ table ) ; if ( null !== $ context ) { $ parameters += $ context -> getForDynamoDB ( ) ; } if ( null !== $ this -> logger ) { $ this -> log ( 'Scan request paramaters : ' . print_r ( $ parameters , true ) , Logger :: DEBUG ) ; } $ response = $ this -> connector -> scan ( $ parameters ) ; if ( null !== $ this -> logger ) { $ this -> log ( 'Scan request response : ' . print_r ( $ response , true ) , Logger :: DEBUG ) ; $ this -> log ( $ response [ 'ScannedCount' ] . ' scanned items' ) ; } $ this -> addConsumedReadUnits ( $ table , floatval ( $ response [ 'ConsumedCapacityUnits' ] ) ) ; if ( isset ( $ response [ 'LastEvaluatedKey' ] ) ) { if ( null === $ context ) { $ nextContext = new Context \ Scan ( ) ; } 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 ; }
Get items via the scan call
@param string $table The item table
@param Context\Scan|null $context The call context
@return Collection
Get items via the scan call