LEFT JOIN ".DB::table('portal_article_title')." a ON a.aid=r.raid
WHERE r.aid='$aid' ORDER BY r.displayorder");
while ($value = DB::fetch($query)) {
$article['related'][] = $value;
}
复制代码
替换成:
$article['related'] = array();
if (empty($article['related'])){
$query = DB::query("SELECT a.aid,a.title
FROM ".DB::table('portal_article_related')." r
LEFT JOIN ".DB::table('portal_article_title')." a ON a.aid=r.raid
WHERE r.aid='$aid' ORDER BY r.displayorder");
}
else{
$query = DB::query("SELECT * FROM ".DB::table('portal_article_title')." a LEFT JOIN ".DB::table('portal_article_count')." b ON a.aid=b.aid WHERE a.catid=$article[catid] AND a.aid!=$aid AND b.viewnum>1 AND b.viewnum<20 ORDER BY b.viewnum ASC ,b.dateline DESC LIMIT 0,10");