diff options
Diffstat (limited to 'modules/comment')
-rw-r--r-- | modules/comment/comment.admin.inc | 2 | ||||
-rw-r--r-- | modules/comment/comment.install | 13 |
2 files changed, 13 insertions, 2 deletions
diff --git a/modules/comment/comment.admin.inc b/modules/comment/comment.admin.inc index c39741cda..fba703d2e 100644 --- a/modules/comment/comment.admin.inc +++ b/modules/comment/comment.admin.inc @@ -174,7 +174,7 @@ function comment_multiple_delete_confirm(&$form_state) { foreach (array_filter($edit['comments']) as $cid => $value) { $comment = comment_load($cid); if (is_object($comment) && is_numeric($comment->cid)) { - $subject = db_result(db_query('SELECT subject FROM {comment} WHERE cid = %d', $cid)); + $subject = db_query('SELECT subject FROM {comment} WHERE cid = :cid', array(':cid' => $cid))->fetchField(); $form['comments'][$cid] = array('#type' => 'hidden', '#value' => $cid, '#prefix' => '<li>', '#suffix' => check_plain($subject) . '</li>'); $comment_counter++; } diff --git a/modules/comment/comment.install b/modules/comment/comment.install index f35b98d81..45afd76bd 100644 --- a/modules/comment/comment.install +++ b/modules/comment/comment.install @@ -42,7 +42,18 @@ function comment_uninstall() { */ function comment_enable() { // Insert records into the node_comment_statistics for nodes that are missing. - db_query("INSERT INTO {node_comment_statistics} (nid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) SELECT n.nid, n.changed, NULL, n.uid, 0 FROM {node} n LEFT JOIN {node_comment_statistics} c ON n.nid = c.nid WHERE c.comment_count IS NULL"); + $query = db_select('node', 'n'); + $query->leftJoin('node_comment_statistics', 'ncs', 'ncs.nid = n.nid'); + $query->addField('n', 'changed', 'last_comment_timestamp'); + $query->addField('n', 'uid', 'last_comment_uid'); + $query->addField('n', 'nid'); + $query->addExpression('0', 'comment_count'); + $query->addExpression('NULL', 'last_comment_name'); + $query->isNull('ncs.comment_count'); + + db_insert('node_comment_statistics') + ->from($query) + ->execute(); } /** |