Posted by ocamp on December 28, 2012 at 9:37pm
im trying to update a node in drupal 7 using te following sql query
db_update('table')
->fields(array(
'column1' => 1 ,
))
->condition('entity_id', 2, '=')
->execute();The statement works as expected, the value of column1 gets updates to 1 where the entity_id = 2.
However im trying to replace 2 with the current node.
If I use Return $node->nid then the current node gets return as expected. If I try to put $node->nid into the query it doesnt validate.
Ie
db_update('table')
->fields(array(
'column1' => 1 ,
))
->condition('entity_id', $node->nid, '=')
->execute();doesnt return anything, the query just fails.
Please help.
Thanks
Comments
What is the context of your
What is the context of your code, there is no global $node
im using it in rules. I've
im using it in rules.
I've set on a certain condition execute php.
Then ive put this as the php.
If i put echo $node->nid the nid will get displayed.
Ivr tried putting global $node above the query but i still cant pass the nid in to the statement.
What is the condition you are
What is the condition you are triggering the rule under?