I've noticed that the following does not work to unpublish nodes:
db_update('node')
->fields(array('status' => 0))
->condition('nid', $array_of_nids, 'IN')
->execute();
But it does if you follow up with the same update on the node_revision
table. (But perhaps I should only be updating the status of the current revision (vid)?)
I found this confusing because the nodes in question do not use revisioning yet it seems that the revision table holds more authoritative data than the main node table (so if so, what's the point of node
table?)
Can anyone explain how node
and node_revision
are related and therefore how to do a bulk update such as this 'properly'? (I'd prefer to avoid a costly loop of node_load
, node_save
if poss.) I'd like to understand the Drupal Way here.
(I have read node revisions which covers D6, but that did not give me the understanding I was after.)