I have written a PHP script for the programmatic creation of nodes:
<?php
define('DRUPAL_ROOT', getcwd());
$_SERVER['REMOTE_ADDR'] = "localhost";
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
// Get a list of Office ID's
$office_ids = db_query('SELECT OFFICE_ID FROM sage.OFFICE');
// Loop through and edit each user
foreach($office_ids as $office) {
// Create a new node object
$node = new stdClass();
// Set our new node content type
$node->type = "office";
// Set the node title
$node->title = "Office " . $office->office_id;
// Set the language
$node->language = LANGUAGE_NONE;
// Set the UID of the author of the node; or use $node->name
$node->uid = 1;
// Set node details
$node->body[$node->language][0]['value'] = $bodytext;
$node->body[$node->language][0]['summary'] = text_summary($bodytext);
$node->body[$node->language][0]['format'] = 'filtered_html';
$path = 'office-' . $office->office_id;
$node->path = array('alias' => $path);
if($node = node_submit($node)) {
node_save($node);
echo "Node with nid" . $node->nid . " saved!\n";
}
}
When I run the above script, I can see my NIDs incrementing (and I assume this means my nodes are created), however when I go and check in the 'nodes' table in the database, I see nothing added.
Does anything know what could be wrong?