/**
  * Delete an item via the delete_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\Delete|null $context The call context
  * @return array|null
  */
 public function delete($table, $hash, $range = null, Context\Delete $context = null)
 {
     if (null !== $this->logger) {
         $this->log('Delete on table ' . $table);
     }
     // Primary key
     $hash = new Attribute($hash);
     $key = array('HashKeyElement' => $hash->getForDynamoDB());
     // Range key
     if (null !== $range) {
         $range = new Attribute($range);
         $key['RangeKeyElement'] = $range->getForDynamoDB();
     }
     $parameters = array('TableName' => $table, 'Key' => $key);
     if (null !== $context) {
         $parameters += $context->getForDynamoDB();
     }
     if (null !== $this->logger) {
         $this->log('Delete request paramaters : ' . print_r($parameters, true), Logger::DEBUG);
     }
     $response = $this->connector->deleteItem($parameters);
     if (null !== $this->logger) {
         $this->log('Delete request response : ' . print_r($response, true), Logger::DEBUG);
     }
     // Update write counter
     $this->addConsumedWriteUnits($table, floatval($response['ConsumedCapacityUnits']));
     return $this->populateAttributes($response);
 }
 public function delete()
 {
     $query = ['TableName' => $this->getTable(), 'Key' => static::getDynamoDbKey($this, $this->getKey())];
     $result = $this->client->deleteItem($query);
     $status = array_get($result->toArray(), '@metadata.statusCode');
     return $status == 200;
 }
 /**
  * @inheritdoc
  */
 public function delete()
 {
     $key = $this->getModelKey($this->getKeyAsArray(), $this);
     $query = ['TableName' => $this->getTable(), 'Key' => $key];
     $result = $this->client->deleteItem($query);
     $status = array_get($result->toArray(), '@metadata.statusCode');
     return $status === 200;
 }
Beispiel #4
0
 /**
  * Delete record
  *
  * @return mixed
  * @link http://docs.aws.amazon.com/aws-sdk-php/latest/class-Aws.DynamoDb.DynamoDbClient.html#_deleteItem
  */
 public function delete()
 {
     $conditions = $this->_getKeyConditions();
     $args = array('TableName' => $this->_table_name, 'Key' => $conditions, 'ReturnValues' => 'ALL_OLD');
     $result = self::$_client->deleteItem($args);
     self::_logQuery('deleteItem', $args, $result);
     return $result;
 }
Beispiel #5
0
 /**
  * Executes the DeleteItem operation.
  *
  * @param string $tableName                   The name of the table from which to delete the item.
  * @param array  $key                         Associative array of <AttributeName> keys mapping to (associative-array) values.
  * @param array  $expected                    This is the conditional block for the DeleteItem operation. All the conditions must be met for the operation to succeed.
  * @param string $conditionnalOperator        Operator between each condition of $expected argument.
  * @param string $returnValues                Use ReturnValues if you want to get the item attributes as they appeared before they were deleted.
  * @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#_deleteItem
  */
 public function deleteItem($tableName, array $key, array $expected = null, $conditionnalOperator = self::COND_AND, $returnValues = self::RETURN_NONE, $returnConsumedCapacity = self::CAPACITY_NONE, $returnItemCollectionMetrics = self::METRICS_NONE)
 {
     $args = ['TableName' => $tableName, 'Key' => $key, 'ConditionnalOperator' => $conditionnalOperator, 'ReturnValues' => $returnValues, 'ReturnConsumedCapacity' => $returnConsumedCapacity, 'ReturnItemCollectionMetrics' => $returnItemCollectionMetrics];
     if ($expected !== null) {
         $args['Expected'] = $expected;
     }
     return $this->client->deleteItem($args);
 }
 /**
  * {@inheritDoc}
  *
  * @throws \Aws\DynamoDb\Exception\DynamoDBException
  *
  * @see http://docs.aws.amazon.com/aws-sdk-php/latest/class-Aws.DynamoDb.DynamoDbClient.html#_deleteItem
  */
 public function delete(EntityInterface $entity, array $commandOptions = array())
 {
     $this->dispatchEntityRequestEvent(Events::ENTITY_PRE_DELETE, $entity);
     $commandOptions += array('TableName' => $this->getEntityTable($entity), 'Key' => $this->formatKeyCondition($entity));
     $model = $this->dynamoDb->deleteItem($commandOptions);
     $this->dispatchEntityResponseEvent(Events::ENTITY_POST_DELETE, $entity, $model);
     return true;
 }
 /**
  * (non-PHPdoc)
  * 
  * @see common_persistence_KvDriver::del()
  */
 public function del($key)
 {
     try {
         $this->client->deleteItem(array('TableName' => $this->tableName, 'Key' => array(self::SIMPLE_KEY_NAME => array('S' => $key))));
         common_Logger::i('DEL: ' . $key);
     } catch (\Exception $ex) {
         return false;
     }
     return true;
 }
 /**
  * @depends testCreatesTable
  */
 public function testAddsGetsAndDeletesItems()
 {
     $attributes = $this->client->formatAttributes(array('foo' => 'Test', 'bar' => 10, 'baz' => 'abc'));
     self::log('Adding an item to the table: ' . var_export($attributes, true));
     $result = $this->client->putItem(array('TableName' => $this->table, 'Item' => $attributes));
     $this->assertTrue(isset($result['ConsumedCapacityUnits']));
     self::log('Getting the item');
     // Get the item using the formatAttributes helper
     $result = $this->client->getItem(array('TableName' => $this->table, 'Key' => $this->client->formatAttributes(array('HashKeyElement' => 'Test', 'RangeKeyElement' => 10)), 'ConsistentRead' => true));
     $this->assertEquals('Test', $result['Item']['foo']['S']);
     $this->assertEquals(10, $result['Item']['bar']['N']);
     $this->assertEquals('abc', $result['Item']['baz']['S']);
     self::log('Deleting the item');
     $result = $this->client->deleteItem(array('TableName' => $this->table, 'Key' => $this->client->formatAttributes(array('HashKeyElement' => 'Test', 'RangeKeyElement' => 10))));
     $this->assertTrue(isset($result['ConsumedCapacityUnits']));
 }
 /**
  * Updates the current session id with a newly generated one.
  * Please refer to {@link http://php.net/session_regenerate_id} for more details.
  * @param boolean $deleteOldSession Whether to delete the old associated session file or not.
  * @since 1.1.8
  */
 public function regenerateID($deleteOldSession = false)
 {
     $oldId = session_id();
     parent::regenerateID(false);
     $newId = session_id();
     $row = $this->getData($oldId);
     if (!is_null($row)) {
         if ($deleteOldSession) {
             // Delete + Put = Update
             $this->dynamoDb->deleteItem(array('TableName' => $this->tableName, 'Key' => array('id' => array('S' => (string) $oldId))));
             $this->dynamoDb->putItem(array('TableName' => $this->tableName, 'Item' => array($this->idColumn => array('S' => (string) $newId), $this->dataColumn => $row[$this->dataColumn], $this->expireColumn => $row[$this->expireColumn])));
         } else {
             $row[$this->idColumn] = array('S' => (string) $newId);
             $this->dynamoDb->putItem(array('TableName' => $this->tableName, 'Item' => array($row)));
         }
     } else {
         $this->dynamoDb->putItem(array('TableName' => $this->tableName, 'Item' => array($this->idColumn => array('S' => $newId), $this->expireColumn => array('N' => $this->getExpireTime()))));
     }
 }
 /**
  * {@inheritDoc}
  */
 public function delete($storageName, $key)
 {
     $result = $this->client->deleteItem(['TableName' => $storageName, 'Key' => ['id' => ['S' => $key]]]);
 }
 public function delete($keys)
 {
     $keyItem = DynamoDbItem::createFromArray($keys, $this->attributeTypes);
     $requestArgs = ["TableName" => $this->tableName, "Key" => $keyItem->getData()];
     $this->dbClient->deleteItem($requestArgs);
 }
Beispiel #12
0
 /**
  * @param $key
  */
 public function delete($key)
 {
     $this->dynamoDbClient->deleteItem(['TableName' => $this->tableName, 'Key' => [$this->attribute => [$this->getVariableType($key) => (string) $key]]]);
 }
 /**
  * {@inheritDoc}
  */
 public function delete($storageName, $key)
 {
     $result = $this->client->deleteItem(array('TableName' => $storageName, 'Key' => array('id' => array('S' => $key))));
 }