我正在使用 amazon sdk v2 并使用 aws factory 进行 dynamoDB 并且我有一个简单的 putItem 操作,但我不知道如何确保 putItem 成功与否,因为 putItem 返回的模型不包含任何有关操作状态的信息。任何想法?这是我的代码
class DynamoLogger{
protected $client;
protected $tableName;
public function __construct(ServiceBuilder $builder, $tableName)
{
$this->client = $builder->get('dynamodb');
$this->tableName = $tableName;
}
public function log(Request $request)
{
$model = $this->client->putItem(array(
'TableName' => $this->tableName,
'Item' => array(
'cc_id' => array(
'S' => $request->get('cc_id')
),
'date' => array(
'S' => date('Y-m-d H:i:s') . substr((string)microtime(), 1, 8)
),
'tt_id' => array(
'N' => $request->get('tt_id')
),
'action_name' => array(
'S' => $request->get('name')
),
'action_value' => array(
'S' => $request->get('value')
),
'gg_nn' => array(
'S' => $request->get('gg_nn')
),
'ffr_id' => array(
'N' => $request->get('ffr_id')
)
),
'ReturnValues' => 'ALL_OLD'
));
return $model;
}
}