2017-06-02 41 views
0

我有以下使用php SDK的DynamoDB更新查詢。DynamoDB updateItem不起作用

$up = $this->dynamoDb->updateItem(array(
      'TableName' => $this->dynamoTable, 
      'Key' => array(
       'id' => array('S' => $id), 
       'time' => array('N' => $time) 
      ), 
      //"ReturnValues" => 'UPDATED_NEW', 
      "UpdateExpression" => "SET #moderated = :val", 
      "ExpressionAttributeNames" => array(
       "#moderated" => "changes_applied", 
      ), 
      "ExpressionAttributeValues" => array(
       ':val' => array('N' => 1) 
      ) 
     )); 
     debug($up); 

但它不工作。當我打印返回的結果時,我得到更新前的相同記錄。

任何人都可以幫我解決問題嗎?

回答

0

看起來像您評論過的返回值。如果沒有指定ReturnValues,則不返回任何內容。

//"ReturnValues" => 'UPDATED_NEW', 

用途: -

"ReturnValues" => 'ALL_NEW', 

ALL_NEW - 返回所有項目的屬性,因爲他們在操作的updateItem出現後 。