If I had written Drupal and CCK ;), now coders could do something like this:


$node = node_create (array('type' => 'myType'));

node_field_add ($node, title, 'Carlos Ray "Chuck" Norris');
node_field_add ($node, body,  'He is born on March 10th, 1940');
...

cck_field_add ($node, age, 68);
cck_field_add ($node, country, 'USA');
...

node_submit ($node);

in order to submit a node via PHP.

I've just checked, and I can say I'm neither the author of Drupal, nor CCK. :(

In the real world, how a Drupal coder can create and "populate" a node in a module?

I've seen several examples, but I've found them not so intuitive for a new Drupal user like me, and they don't explain how to add CCK fields.
(Blogapi example, Drupal_execute example, William OConnor similar example, etc)

Comments