$SelectSQL .= $relcalc.$popcalc.$ratecalc." as Relevance, ";
$SelectSQL .= $this->SourceTable.".".$idField." as ItemId, ".$this->SourceTable.".ResourceId as ResourceId, CONCAT($typestr) as ItemType, EditorsPick as EdPick FROM ".$this->SourceTable." ";
foreach($this->Relationships as $JoinTable=>$OnClause)
{
$SelectSQL .= "LEFT JOIN $JoinTable ON $OnClause ";
}
$first=1;
$where=0;
foreach($this->FieldList as $field)
{
if(strpos($field,"as")>0)
{
$fparts = explode("as",$field,2);
$f = $fparts[1];
$this->AddSearchWhereClause($field);
}
else {
$this->AddSearchWhereClause($field);
}
}
$SelectSQL .= " WHERE ";
$SelectSQL .= implode(" or ",$this->WhereClauses);
if(is_array($idlist))
{
$SelectSQL .= " AND (ResourceId IN (".implode(",",$idlist)."))";