summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2001-10-13 08:34:58 +0000
committerDries Buytaert <dries@buytaert.net>2001-10-13 08:34:58 +0000
commit0a5e1828f420a6e3c24e42c14bb7006e9368e8a9 (patch)
tree0e5b549cc1e8355f7f7d9321298c7482325a8411
parent73d61b7839c407cee996a6d79f7d4bce63e81d87 (diff)
downloadbrdo-0a5e1828f420a6e3c24e42c14bb7006e9368e8a9.tar.gz
brdo-0a5e1828f420a6e3c24e42c14bb7006e9368e8a9.tar.bz2
- Fixed the remaining SQL problems when running MySQL in ANSI mode.
(moderation/comment related)
-rw-r--r--includes/comment.inc10
-rw-r--r--modules/blog.module11
-rw-r--r--modules/blog/blog.module11
3 files changed, 5 insertions, 27 deletions
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 "<ul>";
@@ -257,7 +257,7 @@ function comment_thread_max($cid, $mode, $threshold, $level = 0, $dummy = 0) {
** in terms of speed and size.
*/
- $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 "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td width=\"". ($level * 25) ."\">&nbsp;</td><td>\n";
@@ -307,7 +307,7 @@ function comment_render($lid, $cid) {
$theme->box(t("Control panel"), $theme->comment_controls($threshold, $mode, $order));
if ($cid > 0) {
- $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.cid = '$cid' GROUP BY 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.cid = '$cid' GROUP BY c.cid, c.pid, c.lid, c.subject, c.comment, c.timestamp, u.uid, u.name");
if ($comment = db_fetch_object($result)) {
comment_view($comment, comment_links($comment));
}
diff --git a/modules/blog.module b/modules/blog.module
index 56d7bfa0c..732da9fa7 100644
--- a/modules/blog.module
+++ b/modules/blog.module
@@ -14,15 +14,6 @@ function blog_help() {
<?php
}
-function blog_cron() {
- $result = db_query("SELECT n.nid, n.timestamp, SUM(m.score) / COUNT(m.cid) AS score, COUNT(m.cid) AS votes FROM node n LEFT JOIN moderate m ON m.nid = n.nid WHERE n.type = 'blog' AND n.status = '". node_status("posted") ."' GROUP BY n.nid, n.title, n.comment, n.timestamp, b.body, u.uid, u.name ORDER BY n.timestamp DESC LIMIT 30");
- while ($node = db_fetch_object($result)) {
- if ($node->score > 3 && $node->votes > 4) {
- db_query("UPDATE node SET promote = '1' WHERE nid = '$node->nid'");
- }
- }
-}
-
function blog_perm() {
return array("administer blogs", "access blogs", "post blogs");
}
@@ -120,7 +111,6 @@ function blog_page_user($uid = 0, $date = 0) {
}
if ($blog->comment) {
- $links[] = "<a href=\"node.php?id=$blog->nid\">". t("moderate") ."</a>";
$links[] = "<a href=\"node.php?id=$blog->nid\">". format_plural($blog->comments, t("comment"), t("comments")) ."</a>";
}
@@ -157,7 +147,6 @@ function blog_page_last() {
}
if ($blog->comment) {
- $links[] = "<a href=\"node.php?id=$blog->nid\">". t("moderate") ."</a>";
$links[] = "<a href=\"node.php?id=$blog->nid\">". format_plural($blog->comments, t("comment"), t("comments")) ."</a>";
}
diff --git a/modules/blog/blog.module b/modules/blog/blog.module
index 56d7bfa0c..732da9fa7 100644
--- a/modules/blog/blog.module
+++ b/modules/blog/blog.module
@@ -14,15 +14,6 @@ function blog_help() {
<?php
}
-function blog_cron() {
- $result = db_query("SELECT n.nid, n.timestamp, SUM(m.score) / COUNT(m.cid) AS score, COUNT(m.cid) AS votes FROM node n LEFT JOIN moderate m ON m.nid = n.nid WHERE n.type = 'blog' AND n.status = '". node_status("posted") ."' GROUP BY n.nid, n.title, n.comment, n.timestamp, b.body, u.uid, u.name ORDER BY n.timestamp DESC LIMIT 30");
- while ($node = db_fetch_object($result)) {
- if ($node->score > 3 && $node->votes > 4) {
- db_query("UPDATE node SET promote = '1' WHERE nid = '$node->nid'");
- }
- }
-}
-
function blog_perm() {
return array("administer blogs", "access blogs", "post blogs");
}
@@ -120,7 +111,6 @@ function blog_page_user($uid = 0, $date = 0) {
}
if ($blog->comment) {
- $links[] = "<a href=\"node.php?id=$blog->nid\">". t("moderate") ."</a>";
$links[] = "<a href=\"node.php?id=$blog->nid\">". format_plural($blog->comments, t("comment"), t("comments")) ."</a>";
}
@@ -157,7 +147,6 @@ function blog_page_last() {
}
if ($blog->comment) {
- $links[] = "<a href=\"node.php?id=$blog->nid\">". t("moderate") ."</a>";
$links[] = "<a href=\"node.php?id=$blog->nid\">". format_plural($blog->comments, t("comment"), t("comments")) ."</a>";
}