Search code examples
amazon-web-servicesamazon-ec2amazon-simpledb

Replacing amazon simpledb attribute value doesnt work


I am working on a project based on Amazon Simpledb. Whenever I put attribute value to an attribute, it adds one more value to the array of attribute value. But, I just want one value per attribute no matter how many times I put to values to that attribute. I have gone through amazon documentation and searched all over but the way they ask us to replace value is not working.

The code that I am using is below:

$item_name = "car4"; 
$putAttributesRequest["make"] = array("value" => "val",'Replace' => true); // replace doesnt work
$sdb->putAttributes($domain,$item_name,$putAttributesRequest));

Please help if you know the right way of replacing. To make this happen I also tried to first delete attribute and then make a new one but somehow delete attribute needs a matching value before deleting. Like below :

$deleteAttributesRequest = array("make"=>"Lexus");
print_r($sdb->deleteAttributes($domain,$item_name,$deleteAttributesRequest));

You can help me either by letting me know how to replace the attribute value or how to delete an attribute which is holding any value.

Thank you so much.


Solution

  • Replace and true must be enclosed with double inverted commas i.e "". Try this -

    $putAttributesRequest["make"] = array("value" => "val", "replace" => "true"); // replace should work
    

    Replace should work. For more detail link.