delete_attributes ( $domain_name, $item_name, $attributes, $opt )

Deletes one or more attributes associated with the item. If all attributes of an item are deleted, the item is deleted.

If you specify DeleteAttributes without attributes or values, all the attributes for the item are deleted.

DeleteAttributes is an idempotent operation; running it multiple times on the same item or attribute does not result in an error response.

Because Amazon SimpleDB makes multiple copies of your data and uses an eventual consistency update model, performing a GetAttributes or Select request (read) immediately after a DeleteAttributes or PutAttributes request (write) might not return the updated data.

Access

public

Parameters

Parameter

Type

Required

Description

$domain_name

string

Required

The name of the domain in which the attributes are being deleted.

$item_name

string

Required

The name of the base item which will contain the series of keypairs.

$attributes

array

Optional

Similar to columns on a spreadsheet, attributes represent categories of data that can be assigned to items. Takes an associative array of parameters that can have the following keys:

  • Attribute - array - Optional - This is the parameter format supported by the web service API. This is the attribute node.
    • x - array - This represents a simple array index.
      • Name - string - Required - The name of the attribute.
      • AlternateNameEncoding - string - Optional - This is the parameter format supported by the web service API. This is the alternate name encoding to use.
      • Value - string - Required - The value of the attribute.
      • AlternateValueEncoding - string - Optional - This is the parameter format supported by the web service API. This is the alternate value encoding to use.

$opt

array

Optional

An associative array of parameters that can have the following keys:

  • Expected - array - Optional - The update condition which, if specified, determines if the specified attributes will be updated or not. The update condition must be satisfied in order for this request to be processed and the attributes to be updated.
    • Name - string - Optional - The name of the attribute involved in the condition.
    • Value - string - Optional - The value of an attribute. This value can only be specified when the exists parameter is equal to true.
    • Exists - string - Optional - True if the specified attribute must exist with the specified value in order for this update condition to be satisfied, otherwise false if the specified attribute should not exist in order for this update condition to be satisfied.
  • curlopts - array - Optional - A set of values to pass directly into curl_setopt(), where the key is a pre-defined CURLOPT_* constant.
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This is useful for manually-managed batch requests.

Returns

Type

Description

CFResponse

A CFResponse object containing a parsed HTTP response.

Examples

Standard syntax for deleting all values under multiple Names.

// Instantiate
$sdb = new AmazonSDB();
$response = $sdb->delete_attributes('example-domain', 'unit-test', array(
	array('Name' => 'key2'),
	array('Name' => 'key3')
));

// Success?
var_dump($response->isOK());
Result:
bool(true)

Standard syntax for deleting specific Name-Value pairs, and all values under another Name.

// Instantiate
$sdb = new AmazonSDB();
$response = $sdb->delete_attributes('example-domain', 'unit-test', array(
	array('Name' => 'key2', 'Value' => 'value1'),
	array('Name' => 'key2', 'Value' => 'value2'),
	array('Name' => 'key3')
));

// Success?
var_dump($response->isOK());
Result:
bool(true)

Shorthand for deleting all values under a given Name.

// Instantiate
$sdb = new AmazonSDB();
$response = $sdb->delete_attributes('example-domain', 'unit-test', array(
	'Name' => 'key1'
));

// Success?
var_dump($response->isOK());
Result:
bool(true)

Shorthand for deleting a specific value under a given Name.

// Instantiate
$sdb = new AmazonSDB();
$response = $sdb->delete_attributes('example-domain', 'unit-test', array(
	'Name' => 'key2',
	'Value' => 'value1'
));

// Success?
var_dump($response->isOK());
Result:
bool(true)

Standard syntax for deleting specific Name-Value pairs, and all values under another Name, provided conditions are met.

// Instantiate
$sdb = new AmazonSDB();

$response = $sdb->delete_attributes('example-domain', 'unit-test', array(
	array('Name' => 'key2', 'Value' => 'value1'),
	array('Name' => 'key2', 'Value' => 'value2'),
	array('Name' => 'key3')
), array(
	'Expected' => array(
		'Name' => 'key99',
		'Value' => 'value1',
		'Exists' => 'true'
	)
));

// Success?
var_dump($response->isOK());
Result:
bool(true)

Related Methods

Source

Method defined in services/sdb.class.php | Toggle source view (23 lines) | View on GitHub

public function delete_attributes($domain_name, $item_name, $attributes = null, $opt = null)
{
    if (!$opt) $opt = array();
    $opt['DomainName'] = $domain_name;
    $opt['ItemName'] = $item_name;

    if ($attributes)
    {
        $opt = array_merge($opt, CFComplexType::map(array(
            'Attribute' => (is_array($attributes) ? $attributes : array($attributes))
        )));
    }

    if (isset($opt['Expected']))
    {
        $opt = array_merge($opt, CFComplexType::map(array(
            'Expected' => $opt['Expected']
        )));
        unset($opt['Expected']);
    }

    return $this->authenticate('DeleteAttributes', $opt, $this->hostname);
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback