Formats a set of values into the DynamoDB attribute value format.
Access
public
Parameters
Parameter |
Type |
Required |
Description |
---|---|---|---|
|
Required |
The values to be formatted. |
|
|
Optional |
The format of the result (based loosely on the type of operation) |
Returns
Type |
Description |
---|---|
The formatted array. |
Examples
Marshal values into DynamoDB-ready formats (arrays of values)
// Instantiate the class $ddb = new AmazonDynamoDB(); $data = array( 'id' => 15, 'title' => 'Foobaring Foo Bar for Foo', 'author' => 'Dr. Foo B. Baz', 'tags' => array('foo', 'bar', 'baz'), 'links' => array(), ); // Format for put_item $attributes1 = $ddb->attributes($data); // Format for update_item $attributes2 = $ddb->attributes($data, 'update'); var_dump($attributes1, $attributes2);Result:
array(4) { ["id"]=> array(1) { ["N"]=> string(2) "15" } ["title"]=> array(1) { ["S"]=> string(25) "Foobaring Foo Bar for Foo" } ["author"]=> array(1) { ["S"]=> string(14) "Dr. Foo B. Baz" } ["tags"]=> array(1) { ["SS"]=> array(3) { [0]=> string(3) "foo" [1]=> string(3) "bar" [2]=> string(3) "baz" } } } array(4) { ["id"]=> array(1) { ["Value"]=> array(1) { ["N"]=> string(2) "15" } } ["title"]=> array(1) { ["Value"]=> array(1) { ["S"]=> string(25) "Foobaring Foo Bar for Foo" } } ["author"]=> array(1) { ["Value"]=> array(1) { ["S"]=> string(14) "Dr. Foo B. Baz" } } ["tags"]=> array(1) { ["Value"]=> array(1) { ["SS"]=> array(3) { [0]=> string(3) "foo" [1]=> string(3) "bar" [2]=> string(3) "baz" } } } }
Source
Method defined in services/dynamodb.class.php | Toggle source view (13 lines) | View on GitHub