function comment_update_7001 in Drupal 7
Change comment status from published being 0 to being 1
Related topics
File
- modules/
comment/ comment.install, line 141 - Install, update and uninstall functions for the comment module.
Code
function comment_update_7001() {
// Choose a temporary status value different from the existing status values.
$tmp_status = db_query('SELECT MAX(status) FROM {comments}')
->fetchField() + 1;
$changes = array(
0 => $tmp_status,
1 => 0,
$tmp_status => 1,
);
foreach ($changes as $old => $new) {
db_update('comments')
->fields(array(
'status' => $new,
))
->condition('status', $old)
->execute();
}
}