From a938e18a1bd36d887010863817470b690fdbf6f3 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Tue, 28 Jul 2009 19:18:08 +0000 Subject: - Patch #491556 by Berdir: completed converting core to DBTNG. Oh my. Kudos to Berdir for this humongous effort. --- modules/comment/comment.install | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'modules/comment/comment.install') 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(); } /** -- cgit v1.2.3