Update node in Drupal 7

update node

// Return all nids of nodes of type "page".
$nids = db_select('node', 'n')
->fields('n', array('nid'))
->fields('n', array('type'))
->condition('n.type', 'type')
->execute()
->fetchCol(); // returns an indexed array
foreach($nids as $nids){
$node = node_load($nids);
if (isset($node)) {
$node->field_external_program_id_['und'][0]['value'] = $nids;
node_save($node);
}

Comments

Popular posts from this blog

Difference between hook_boot and hook_init Drupal

Difference between DBMS and RDBMS?