Content Type : VideoDisplay

Fields : Name of Video(Type: String), Video(Type: Video Embed Field), Artist(Type : Node Reference Field)

User already created a record of type VideoDisplay. Now as per requirement I can add more

Artist to Existing Video.

So I take this approach:-

$node_vids = node_load($videoId);
$node_vids->field_artist[LANGUAGE_NONE] = array(
               0 => array('nid' => $form_state['values']['nid']));
$node = node_submit($node_vids);

But it gives me error saying:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'node-143-0-0-und' for key 'PRIMARY'

This error comes up while inserting data in Video(Type:Video Embed Field). But here I want to save Artist(Type : Node Reference Field) field only. I get to know that node_save actually saves all the attributes of Content Type.

After searching net I try to use field_attach_update() but again it is throwing same exception. Please let me know any solution to get out of this problem.

1 Answer 1


field_sql_storage_field_storage_write() function exposed by Drupal helps to update desired single field only. Calling this will not invoke any hooks.

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.