function computing_update_field in Drupal Computing 7.2
Only update and persist the given field. This is supposed to save bandwidth between Drupal and Agent by only updating one field instead of the entire object. It only handles the database properties of the entity, or single value field. Use your own functions if need to override to handle more advanced data types.
Parameters
$id int: the entity of of the computing record to be updated.:
$field_name string: the name of the field.:
$field_value object: the value of the field. if field name is "input" or "output", do json encode (to avoid json encode, use computing_update() directly instead).:
Return value
bool: TRUE if successful. FALSE if not successful.
3 calls to computing_update_field()
- ComputingQueue::deleteItem in ./
computing.queue.inc - Delete a finished item from the queue.
- computing_claim in ./
computing.module - Return an object and mark it as being processed. Use lock system to make sure status is not changed during the process. Another approach is to use while(TRUE) following the logic from SystemQueue:claimItem().
- computing_release in ./
computing.module - Release the claimed record, assuming that the record is claimed by the
1 string reference to 'computing_update_field'
- computing_services_resources in ./
computing.services.inc - Implements hook_services_resources().
File
- ./
computing.module, line 270
Code
function computing_update_field($id, $field_name, $field_value) {
$entity_info = entity_get_info('computing_record');
$record = computing_load($id);
if ($record && isset($record->application)) {
$fields_info = field_info_instances('computing_record', $record->application);
if (in_array($field_name, $entity_info['schema_fields_sql']['base table'])) {
// this is a basic property.
$record->{$field_name} = $field_value;
return computing_update($record);
}
else {
if (array_key_exists($field_name, $fields_info)) {
// use $wrapper to avoid direct set multi-value field, etc.
$wrapper = entity_metadata_wrapper('computing_record', $record);
$wrapper->{$field_name}
->set($field_value);
return computing_update($wrapper
->value());
}
}
}
// all other cases return FALSE.
return FALSE;
}