The scenario goes this way, I have a node type which has lot of Taxonomy term fields in it. It does also have other fields like text, date etc but 90% of it is a taxonomy field. I am aware that a node can be created programatically in two ways,
node_save() - Creating a node object and saving it
$node = new stdClass();
$node->type = 'article';
$node->field_term[LANGUAGE_NONE][0]['tid'] = 3128 // term id of the term
node_save($node);
$node = new stdClass(); $node->type = 'article'; $node->field_term[LANGUAGE_NONE][0]['tid'] = 3128 // term id of the term node_save($node);
Form submit - creating a form array and submitting using drupal_form_submit
$node[field_first][und] => chennai;
$node[field_second] [und] => "iphone5";
$node['type'] = 'article';
$form_state['values'] = $node;
$form_state['values']['op'] = t('Save');
drupal_form_submit($node_type . '_node_form', $form_state, (object)$node);
$node[field_first]['und'] => chennai; $node[field_second]['und'] => "iphone5"; $node['type'] = 'article'; $form_state['values'] = $node; $form_state['values']['op'] = t('Save'); drupal_form_submit($node_type . '_node_form', $form_state, (object)$node);
with $node having the POST values.
Advantage of using form submit method is Drupal will take care of creating new terms in vocabulary (I am supposed to get more new terms). Form submit can follow form validations which is needed for creating a node.
The Question here is isIs there any method to create nodes faster in to drupalDrupal system which supposed to get more terms in it?
ifIf there is no other method than the above mentioned, what is the best one ? if node_save is chosen why?