" JOIN ^posts AS childposts ON parentposts.postid=IF(LEFT(childposts.type, 1)='Q', childposts.postid, childposts.parentid)".
" WHERE childposts.postid IN (#)";
...
...
@@ -789,10 +812,11 @@ function qa_db_post_meta_selectspec($postid, $title)
'arrayvalue'=>'content',
);
if(is_array($title))
if(is_array($title)){
$selectspec['arraykey']='title';
else
}else{
$selectspec['single']=true;
}
return$selectspec;
}
...
...
@@ -946,8 +970,9 @@ function qa_db_search_posts_selectspec($voteuserid, $titlewords, $contentwords,
}
}
if($selectparts==0)
if($selectparts==0){
$selectspec['source'].='(SELECT NULL as questionid, 0 AS score, NULL AS matchposttype, NULL AS matchpostid FROM ^posts WHERE postid IS NULL)';
}
$selectspec['source'].=") x LEFT JOIN ^posts ON ^posts.postid=questionid GROUP BY questionid ORDER BY score DESC LIMIT #,#) y ON ^posts.postid=y.questionid";
...
...
@@ -995,9 +1020,9 @@ function qa_search_set_max_match($question, &$type, &$postid)
'source'=>'^users JOIN (SELECT userid FROM ^userpoints ORDER BY points DESC LIMIT #,#) y ON ^users.userid=y.userid JOIN ^userpoints ON ^users.userid=^userpoints.userid',
'source'=>'^users JOIN (SELECT userid FROM ^userpoints ORDER BY points DESC LIMIT #,#) y ON ^users.userid=y.userid JOIN ^userpoints ON ^users.userid=^userpoints.userid',
'arguments'=>array($start,$count),
'arraykey'=>'userid',
'sortdesc'=>'points',
);
}
...
...
@@ -1595,8 +1622,9 @@ function qa_db_recent_messages_selectspec($fromidentifier, $fromisuserid, $toide
if(isset($fromidentifier)){
$fromsub=$fromisuserid?'$':'(SELECT userid FROM ^users WHERE handle=$ LIMIT 1)';
$where='fromuserid='.$fromsub." AND type='PRIVATE'";
}else
}else{
$where="type='PUBLIC'";
}
$tosub=$toisuserid?'$':'(SELECT userid FROM ^users WHERE handle=$ LIMIT 1)';
$source='^messages LEFT JOIN ^users ufrom ON fromuserid=ufrom.userid LEFT JOIN ^users uto ON touserid=uto.userid WHERE '.$where.' AND touserid='.$tosub.' ORDER BY ^messages.created DESC LIMIT #,#';