- ⌂ cObject
- Methods
- Constructor
- add_variant()
- approve()
- as_array()
- can_add_variant()
- can_delete_variant()
- can_edit_variant()
- can_reorder_variant()
- clone()
- delete()
- edit_variant()
- enum()
- get_active_object()
- get_all_variants()
- get_attributes()
- get_dimensions()
- get_dimension_with()
- get_parent()
- get_primary_cpath()
- get_variant()
- Keywords()
- lock_object()
- reload_data()
- repo()
- revert()
- save()
- store()
- unlock_object()
- update_from_array()
- validate()
cObject::update_from_array()
Updates an object based on key/value pairs in an associative array. The keys must match the field identifiers exactly. Values will be copied or dereferenced for reference fields. Deep embedded content will be created/updated as well. If the associate array contains deep information about referenced objects, it will be ignored. Only embedded content is updated/created.
Prototype
boolean update_from_array(array $array, array $options = [], array $oid_map = FALSE)
Parameters
- array - Associative array of key/value pairs where the keys match field identifiers. Collections can be represented by arrays and embedded objects can be nested as more associative arrays. Referenced objects will not be updated, so their key/value pairs will be ignored beyond what is needed to match on what to reference.
- options - Associative array of options to alter the behavior of how the associative array is interpreted.
- base_file_path - where to look for referenced files when a relative path is provided.
- oid_map - Associative array where the key is an object OID and the value is the cObject that it maps to. This will be used if an OID is provided as the key of a referenced object.
Return
TRUE if the object was updated successfully. FALSE if there was an error.
Example
$repo = \comand::repo();
$contact = $repo->get_first('FROM Contact LIMIT 1');
$contact->update_from_array([
'FirstName' => 'Jim',
'LastName' => 'Smith'
]);