Question

I have the following code which inputs new items into a domain for SimpleDB. I am using AWS SDK For PHP Version 2.

  $client->putAttributes(array(
     'DomainName' => $domainName,
     'ItemName'   => $uniqueid,
     'Attributes' => array(
         array('Name' => 'USER_ID', 'Value' => $uniqueid, 'Replace' => true),
         array('Name' => 'EMAIL', 'Value' => $email, 'Replace' => true),
         array('Name' => 'CREATED', 'Value' => $date, 'Replace' => true),
         array('Name' => 'LAST_UPDATED', 'Value' => $date, 'Replace' => true),
     )
  ));

How do I do a conditional put? I want the conditional to be that EMAIL does not exist. It's something like: Expected.Name => EMAIL Expected.Exists => False but I don't know the syntax.

Here is a link to the API Docs. I don't understand them well enough to implement this. http://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.SimpleDb.SimpleDbClient.html#_putAttributes

Thanks!

Was it helpful?

Solution

This seems to work. I am now getting a conditional check failed error.

$client->putAttributes(array(
    'DomainName' => $domainName,
    'ItemName'   => $uniqueid,
    'Attributes' => array(
        array('Name' => 'USER_ID', 'Value' => $uniqueid, 'Replace' => true),
        array('Name' => 'EMAIL', 'Value' => $email, 'Replace' => true),
        array('Name' => 'CREATED', 'Value' => $date, 'Replace' => true),
        array('Name' => 'LAST_UPDATED', 'Value' => $date, 'Replace' => true),
    ),
    'Expected' => array('Name' => 'EMAIL', 'Exists' => false),
));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top