* Small bugfixes and minor updates.

3-00
Dries Buytaert 2000-06-25 16:53:56 +00:00
parent 18ee415456
commit 9966696dd6
2 changed files with 3 additions and 3 deletions

View File

@ -8,7 +8,7 @@ $number = ($user->storynum) ? $user->storynum : 10;
$date = ($date) ? $date : time();
### Perform query:
$result = db_query("SELECT stories.*, users.userid, COUNT(comments.sid) AS comments FROM stories LEFT JOIN comments ON stories.id = comments.sid LEFT JOIN users ON stories.author = users.id WHERE stories.status = 2 AND stories.timestamp <= $date GROUP BY stories.id ORDER BY stories.id DESC LIMIT $number");
$result = db_query("SELECT stories.*, users.userid, COUNT(comments.sid) AS comments FROM stories LEFT JOIN comments ON stories.id = comments.sid LEFT JOIN users ON stories.author = users.id WHERE stories.status = 2 AND stories.timestamp <= $date GROUP BY stories.id ORDER BY stories.timestamp DESC LIMIT $number");
// Note on performance:
// we use a LEFT JOIN to retrieve the number of comments associated
// with each story. By retrieving this data now (outside the while-

View File

@ -26,8 +26,8 @@ function submission_vote($id, $vote) {
### Update story table (if required):
$result = db_query("SELECT * FROM stories WHERE id = $id");
if ($submission = db_fetch_object($result)) {
if ($submission->score >= $submission_post_threshold) db_query("UPDATE stories SET status = 2 WHERE id = $id");
if ($submission->score <= $submission_dump_threshold) db_query("UPDATE stories SET status = 0 WHERE id = $id");
if ($submission->score >= $submission_post_threshold) db_query("UPDATE stories SET status = 2, timestamp = '". time() ."' WHERE id = $id");
if ($submission->score <= $submission_dump_threshold) db_query("UPDATE stories SET status = 0, timestamp = '". time() ."' WHERE id = $id");
}
}
}