'SELECT userid FROM ((SELECT DISTINCT userid FROM ^posts WHERE userid>=# ORDER BY userid LIMIT #) UNION (SELECT DISTINCT userid FROM ^uservotes WHERE userid>=# ORDER BY userid LIMIT #)) x ORDER BY userid LIMIT #',
$startuserid,$count,$startuserid,$count,$count
));
else
}else{
returnqa_db_read_all_values(qa_db_query_sub(
'SELECT DISTINCT userid FROM ^users WHERE userid>=# ORDER BY userid LIMIT #',
@@ -94,11 +94,12 @@ function qa_db_userflags_clear_all($postid)
*/
functionqa_db_post_recount_votes($postid)
{
if(qa_should_update_counts())
if(qa_should_update_counts()){
qa_db_query_sub(
'UPDATE ^posts AS x, (SELECT COALESCE(SUM(GREATEST(0,vote)),0) AS upvotes, -COALESCE(SUM(LEAST(0,vote)),0) AS downvotes FROM ^uservotes WHERE postid=#) AS a SET x.upvotes=a.upvotes, x.downvotes=a.downvotes, x.netvotes=a.upvotes-a.downvotes WHERE x.postid=#',
$postid,$postid
);
}
}
...
...
@@ -108,11 +109,12 @@ function qa_db_post_recount_votes($postid)
*/
functionqa_db_post_recount_flags($postid)
{
if(qa_should_update_counts())
if(qa_should_update_counts()){
qa_db_query_sub(
'UPDATE ^posts AS x, (SELECT COALESCE(SUM(IF(flag, 1, 0)),0) AS flagcount FROM ^uservotes WHERE postid=#) AS a SET x.flagcount=a.flagcount WHERE x.postid=#',