Thursday, 27 December 2018

node_save in drupal have issue while storing the values to mysql database

I got an issue in node_save in drupal.

below is my code

function retrax_notify_create(){

    $nodeId = array();  
    $nodeObj = new stdClass(); // We create a new node object
    $nodeObj->type = "re_trax_comments_and_notes"; // Or any other content type you want
    $nodeObj->title = "Re-Trax Comments";
    $nodeObj->language = LANGUAGE_NONE; 
    node_object_prepare($nodeObj); // Set some default values.


    $nodeObj->uid = 474; 

        $nodeObj->field_userid_ref['und'][0]['value'] = '5';

        $nodeObj->field_siteid_ref['und'][0]['value'] = '6';

        $nodeObj->field_notify_count['und'][0]['value'] = 7;


    $nodeObj = node_submit($nodeObj); 
    node_save($nodeObj);
    $nodeId[nid] = $nodeObj->nid;

    echo '<pre>';
    print_r($nodeObj);
    return $nodeId;         

}

Now when i run the hook menu, Default values like type ,title, uid will be stored in node table and node id will also get generated.

But the values for other three table will not get saved for

field_data_field_userid_ref

field_data_field_siteid_ref

field_data_field_notify_count

All the content types are proper but still the value is not being saved to the respective tables.



from node_save in drupal have issue while storing the values to mysql database

No comments:

Post a Comment