Skip to content

Instantly share code, notes, and snippets.

@entendu
Created August 14, 2012 22:52
Show Gist options
  • Select an option

  • Save entendu/3353691 to your computer and use it in GitHub Desktop.

Select an option

Save entendu/3353691 to your computer and use it in GitHub Desktop.
<?php
 $result = db_query("SELECT nid FROM node WHERE type IN ('how_to','quick_start_guides')");
 $i = 1;
 $total = $result->rowCount();
 $types = array('how_to' => array(), 'quick_start_guides' => array(), 'document' => array());
 foreach ($result as $row) {
   $node_comment = node_load($row->nid);
   $types[$node_comment->type][] = $row->nid;
//    $node_comment->comment = "2";
   node_save($node_comment);
   print "Saved nid " . $row->nid . ". " . $i . " of " . $total . " nodes complete.\n";
   $i++;
 }
 
 $howtos = count($types['how_to']);
 $qsg = count($types['quick_start_guides']);
 $doc = count($types['document']);
 print "\n";
 print "\n";
 print "=============Summary==============\n";
 print "Total nodes processed: " . $total . "\n";
 print "# of how_to nodes processed: " . $howtos . "\n";
 print "# of qsg nodes processed: " . $qsg . "\n";
 print "# of doc nodes processed: " . $doc . "\n";
 print "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment