Drupal 6 example:
<?php $node = new stdClass(); type = 'library'; //Name of the content type $node->field_book_no[0][value] = 22;//Book number CCK Field $node->field_book_name[0][value] = "Drupal"; //Book name CCK Field $node->field_book_author[0][value]='Sachin'; //Author name - CCK field $node->field_year[0][value]='2011'; //Publication year - CCK field $node->uid = 1; // user id, 1 is created by admin $node->status = 1;//1 is published, 0 is unpublished $node->promote = 0;//1 is promote to home page, 0 is not to promote on home page node_save($node); // Save this node ?>
node_load () does not return anything, so it does not check.
You can check this with:
$new_node = node_load($node->nid, NULL, TRUE);
If 3d arg will reset the cache before loading node. Expensive, but this is the only way I know.
Then you will need to check node β [vars] against each other and return TRUE if they all match.
I credit http://www.learn-drupal.in/cck/how-to-create-a-drupal-node-programmatically.html with the above node_save code example.
source share