I have a cck field in a node. I bring this value out in some other form and alter its value, But i am unable to save it back to DB. How should i write it back to table such that node changed date also gets changed. please show some code for this.
2 Answers
You can use node_save()
to do this; CCK will automatically hook into it and update the field values in the database for you:
// Load a node
$node = node_load(1);
// Update the field value
$node->field_field_name = array(0 => array('value' => 'A value'));
// Save the node. Field values are also saved, and the node modified time is updated.
node_save($node);