I try to update content type field MYFIELD with code

$update = db_update('field_data_field_MYFIELD')
    -> fields(array('field_MYFIELD_value' => $result))
    -> condition('entity_id', $nid)
    -> execute();

I see changes in database but they not reflected in node view. Also I applied this code to field_revision_field_MYFIELDtable and got the same result. How can I update MYFIELD programmatically?

  • If your database is updated but the changes are not reflected in the node view, I would suggest first trying to clear all cache. But as sam2de said it is better to use the Drupal API for changes to field data.
    – n30r3b3l
    Aug 26, 2015 at 17:08

2 Answers 2


Better( and simpler) solution is using with drupal Node load and Node save API


It's better to use Drupa API to do that instead of missing with the database directly. you can use field_attach_update to update your field value

$node = node_load($nid);
$field = field_language('node', $node, 'field_your_field');
$node->field[$field_language][0]['value'] = 'Your New value';
field_attach_update('node', $node);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.