Hello,
I develop a Drupal module in order to update a custom CCK field belonging to some nodes; for that I defined a mymodule_cron function in which a SQL query is executed. I have something like:
function mymodule_cron() {
...
db_query("UPDATE node LEFT JOIN... SET ... = ...");
}To test my function I trigger the cron manually, and I'm sure the function is well called; I'm also sure that the SQL query is correct and that one record is affected by the update: I tested the SQL in myphpAdmin (the CCK field is well modified), and when I trace the result of the db_query in the wathdog I get 1.
The strange thing for me is that, after the execution of the function, I don't see the modification on the CCK field, even if clear all Drupal cache.
I would appreciate any help and idea ;-)
Bertrand.
Comments
Hi, have you tried with
Hi, have you tried with
node_load
change field X in the node loaded
node_save
?
ZioBudda
Freelancer Senior Drupal Developer -- http://www.ziobuddalabs.it
Thank you!
Thank you for your help, my module works now.
This post: "Update CCK Fields In Custom Drupal Nodes" (http://balancedscale.com/blog/201006/update-cck-fields-custom-drupal-nodes) helps me a lot.
Here my cron function:
Cheers,
Bertrand
odelia technologies, http://www.odelia-technologies.com
Great, but (only for a
Great, but (only for a stilistyc code comment) "node_submit" is useless.
From the api for node_submit: "Prepares a node for saving by populating teaser, author, and creation date".
You already have this data.
ZioBudda
Freelancer Senior Drupal Developer -- http://www.ziobuddalabs.it
It sounds strange but this
It sounds strange but this implementation doesn't work if used into a custom action. This action is called into a triggered rule and it seems that node changes are overwritten during the rule execution workflow.