From 0a5e1828f420a6e3c24e42c14bb7006e9368e8a9 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 13 Oct 2001 08:34:58 +0000 Subject: - Fixed the remaining SQL problems when running MySQL in ANSI mode. (moderation/comment related) --- includes/comment.inc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'includes') diff --git a/includes/comment.inc b/includes/comment.inc index 4f4531e14..8ac81fbfa 100644 --- a/includes/comment.inc +++ b/includes/comment.inc @@ -176,13 +176,13 @@ function comment_order($order) { function comment_query($lid, $order, $pid = -1) { - $query .= "SELECT u.*, c.*, SUM(m.score) / COUNT(m.cid) AS score, COUNT(m.cid) AS votes FROM comments c LEFT JOIN users u ON c.author = u.uid LEFT JOIN moderate m ON c.cid = m.cid WHERE c.lid = '$lid'"; + $query .= "SELECT c.cid, c.pid, c.lid, c.subject, c.comment, c.timestamp, u.uid, u.name, AVG(m.score) AS score, COUNT(m.cid) AS votes FROM comments c LEFT JOIN users u ON c.author = u.uid LEFT JOIN moderate m ON c.cid = m.cid WHERE c.lid = '$lid'"; if ($pid >= 0) { $query .= " AND pid = '$pid'"; } - $query .= " GROUP BY c.cid"; + $query .= " GROUP BY c.cid, c.pid, c.lid, c.subject, c.comment, c.timestamp, u.uid, u.name"; if ($order == 1) { $query .= " ORDER BY c.timestamp DESC"; @@ -235,7 +235,7 @@ function comment_view($comment, $folded = 0) { function comment_thread_min($cid, $threshold) { global $user; - $result = db_query("SELECT u.*, c.*, SUM(m.score) / COUNT(m.cid) AS score, COUNT(m.cid) AS votes FROM comments c LEFT JOIN users u ON c.author = u.uid LEFT JOIN moderate m ON c.cid = m.cid WHERE c.pid = '$cid' GROUP BY c.cid ORDER BY c.timestamp, c.cid"); + $result = db_query("SELECT c.cid, c.pid, c.lid, c.subject, c.comment, c.timestamp, u.uid, u.name, AVG(m.score) AS score, COUNT(m.cid) AS votes FROM comments c LEFT JOIN users u ON c.author = u.uid LEFT JOIN moderate m ON c.cid = m.cid WHERE c.pid = '$cid' GROUP BY c.cid, c.pid, c.lid, c.subject, c.comment, c.timestamp, u.uid, u.name ORDER BY c.timestamp"); while ($comment = db_fetch_object($result)) { print "