Last updated February 12, 2013. Created by glass.dimly on September 11, 2009.
Edited by chrisjlee. Log in to edit this page.
This snippit allows you to bulk enable or disable comments for nodes through the database.
SQL to disable comments for all nodes of type "story":UPDATE node SET comment = 0 WHERE type LIKE "story";
comment = 2 would mass enable read/write
comment = 1 would mass enable just read
You can change "story" to "page" or whatever you'd like.
Comments
thanks
that is exactly what I need
Bevin
Well, yes. But...
Well, yes. But...
-- Would love to provide a UI to choose a large number of nodes, but not all of a type.
-- I prefer not to do this kind of thing in production.
D7
http://drupal.org/node/103064#comment-4922950
You wanna do this via the
You wanna do this via the abstraction layer, do ya?
Yeah, I know you do.
That's why I'm here to help you out, friend!!
<?php
$subquery = db_select('node');
$subquery->addField('node', 'nid');
$subquery->condition('node.type', 'YOUR_NODE_TYPE', '=');
$num_updated = db_update('node_revision')
->fields(array('comment' => '2',))
->condition ('node_revision.nid', $subquery, 'IN')
->execute();
?>
I couldn't figure out how to do a join in a db_update.
Is it possible?
You need to change the
You need to change the setting in the node revisions table as well. Maybe something like the following in addition to the original query:
UPDATE node_revision, node SET node_revision.comment = 2 WHEREnode_revision.nid = node.nid AND
node.type = "story";
content2zero.com
Thank you ! A lot easier than using boring unclear VBO !
Thank you ! A lot easier than using boring unclear VBO !