本文整理汇总了PHP中Aws\DynamoDb\DynamoDbClient::deleteItem方法的典型用法代码示例。如果您正苦于以下问题:PHP DynamoDbClient::deleteItem方法的具体用法?PHP DynamoDbClient::deleteItem怎么用?PHP DynamoDbClient::deleteItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aws\DynamoDb\DynamoDbClient
的用法示例。
在下文中一共展示了DynamoDbClient::deleteItem方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
/**
* 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);
}
示例2: delete
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;
}
示例3: delete
/**
* @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;
}
示例4: delete
/**
* 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;
}
示例5: deleteItem
/**
* 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);
}
示例6: delete
/**
* {@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;
}
示例7: del
/**
* (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;
}
示例8: testAddsGetsAndDeletesItems
/**
* @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']));
}
示例9: regenerateID
/**
* 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()))));
}
}
示例10: delete
/**
* {@inheritDoc}
*/
public function delete($storageName, $key)
{
$result = $this->client->deleteItem(['TableName' => $storageName, 'Key' => ['id' => ['S' => $key]]]);
}
示例11: delete
public function delete($keys)
{
$keyItem = DynamoDbItem::createFromArray($keys, $this->attributeTypes);
$requestArgs = ["TableName" => $this->tableName, "Key" => $keyItem->getData()];
$this->dbClient->deleteItem($requestArgs);
}
示例12: delete
/**
* @param $key
*/
public function delete($key)
{
$this->dynamoDbClient->deleteItem(['TableName' => $this->tableName, 'Key' => [$this->attribute => [$this->getVariableType($key) => (string) $key]]]);
}
示例13: delete
/**
* {@inheritDoc}
*/
public function delete($storageName, $key)
{
$result = $this->client->deleteItem(array('TableName' => $storageName, 'Key' => array('id' => array('S' => $key))));
}