function comment_update_7001

Change comment status from published being 0 to being 1

Related topics

Archivo

drupal-7.x/modules/comment/comment.install, line 144
Install, update and uninstall functions for the comment module.

Código

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();
  }
}