Skip to content

Instantly share code, notes, and snippets.

@ecorson
Created May 8, 2012 15:33
Show Gist options
  • Save ecorson/2636376 to your computer and use it in GitHub Desktop.
Save ecorson/2636376 to your computer and use it in GitHub Desktop.
Iterate over nodes via bootstrap and drush
<?php
$stdout = fopen('php://stdout', 'w');
fwrite($stdout, "Script Template\n");
// Site specific variables
$username = "Dale";
$drupal_base_url = parse_url('http://www.example.com');
require_once 'includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$result = db_query("SELECT nid, title FROM {node} WHERE type = :type", array(
':type' => 'page',
));
$nids = array();
foreach($result as $node) {
$nids[] = $node->nid;
}
echo join(', ', $nids);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment