By cyrill on
Hello!
I need create and update nodes by my module. Some nodes hav cck fields
Tell me please, what is better to use 'node_save' or 'drupal_execute'?
And how can i update nodes by 'drupal_execute'?
Thank you!
Hello!
I need create and update nodes by my module. Some nodes hav cck fields
Tell me please, what is better to use 'node_save' or 'drupal_execute'?
And how can i update nodes by 'drupal_execute'?
Thank you!
Comments
node_save. Just feed it a
node_save. Just feed it a reasonable looking $node object and it will take care of the rest, including supplying defaults in many cases.
>And how can i update nodes by 'drupal_execute'?
Don't know, I've never tried. No need to.
gpk
----
www.alexoria.co.uk
When using node_save() it's
When using node_save() it's generally a good practice to call node_submit() first. So the generally sequence is
The difference is...
...drupal_execute mimics node creation via a form. This includes form data validation, which needs to be handled programmatically if it fails. node_save just processes the object data directly so you must pre-validate the data yourself.
I would start by using node_save and advance to drupal_execute if your needs become more sophisticated.