0

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);
node_save($node);

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.

0

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

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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