Integrity constraint violation: 1062 Duplicate entry for Video Embed Field

358 Views Asked by At

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.

1

There are 1 best solutions below

0
On

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