Formats a value into the DynamoDB attribute value format (e.g. array('S' => 'value')
).
Access
public
Parameters
Parameter |
Type |
Required |
Description |
---|---|---|---|
|
Required |
The value to be formatted. |
|
|
Optional |
The format of the result (based loosely on the type of operation) |
|
|
Optional |
Any valid attribute type to override the calculated type. |
Returns
Type |
Description |
---|---|
An attribute value suitable for DynamoDB. |
Examples
Marshal values into DynamoDB-ready formats (single values)
// Instantiate the class $ddb = new AmazonDynamoDB(); $attribute1 = $ddb->attribute('foo'); $attribute2 = $ddb->attribute(1); $attribute3 = $ddb->attribute(array('foo', 'bar', 'baz')); $attribute4 = $ddb->attribute(array(1, 2, 3)); var_dump($attribute1, $attribute2, $attribute3, $attribute4);Result:
array(1) { ["S"]=> string(3) "foo" } array(1) { ["N"]=> string(1) "1" } array(1) { ["SS"]=> array(3) { [0]=> string(3) "foo" [1]=> string(3) "bar" [2]=> string(3) "baz" } } array(1) { ["NS"]=> array(3) { [0]=> string(1) "1" [1]=> string(1) "2" [2]=> string(1) "3" } }
Marshal attribute values into DynamoDB-ready formats (single value for update)
// Instantiate the class $ddb = new AmazonDynamoDB(); $attribute1 = $ddb->attribute(1, 'put'); $attribute2 = $ddb->attribute(1, 'update'); var_dump($attribute1, $attribute2);Result:
array(1) { ["N"]=> string(1) "1" } array(1) { ["Value"]=> array(1) { ["N"]=> string(1) "1" } }
Source
Method defined in services/dynamodb.class.php | Toggle source view (33 lines) | View on GitHub