$query = DB::query("SELECT DISTINCT t.* $sqlfield FROM `".DB::table('forum_thread')."` t $sqlfrom WHERE {$maxwhere}t.readperm='0' $sql AND t.displayorder>='0' ORDER BY rand() LIMIT $startrow,$items;");
}else{
$query = DB::query("SELECT DISTINCT t.*$sqlfield
FROM `".DB::table('forum_thread')."` t
$sqlfrom WHERE {$maxwhere}t.readperm='0'
$sql
AND t.displayorder>='0'
ORDER BY t.$orderby DESC
LIMIT $startrow,$items;"
);
}
复制代码
[colorT]就是在数据查询的外层加上了判断,如果是随机排序,查询里排序条件就用ORDER BY rand(),否则按原本的排序条件。[/colorT]