/**
按tag标签关联文章内容 query2为备用,如果query为空的话,第二个就直接显示出来
*/
$query = "SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule, tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath FROM `dede_archives` arc LEFT JOIN `dede_arctype` tp on arc.typeid=tp.id WHERE $keyword and arc.ismake = 1 and arc.id <> $arcid ORDER BY arc.sortrank desc LIMIT 0,$row";
$typeids=$refObj->Fields['typeid'];//取出当前栏目ID
$query2 = "SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule, tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath FROM `dede_archives` arc LEFT JOIN `dede_arctype` tp on arc.typeid=tp.id WHERE FIND_IN_SET('c', arc.flag)>0 and arc.ismake = 1 And (arc.typeid in ($typeids) or arc.typeid2 in($typeids) or CONCAT( ',', arc.typeid2, ',' ) LIKE '%,$typeids,%' ) And arc.arcrank > -1 ORDER BY arc.sortrank desc LIMIT 0,$row";
/*query3是判断是否为空用的*/
$query3 = "SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule, tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath FROM dede_archives arc LEFT JOIN dede_arctype tp on arc.typeid=tp.id WHERE $keyword and arc.ismake = 1 and arc.id <> $arcid ORDER BY arc.sortrank desc LIMIT 0,$row";//这里的SQL具体按自己的
数据库的表字段写吧,我这是直接写死了,哎没办法,能力有限。
/*
这里是判断tags标签查询的是否为空值,如果是空值,就全部使用推荐返回值,如果有值,就直接显示tags关联。
*/
$result =mysql_query($query3);//query36判断专用的,主要是作者不会用SetQuery呀,郁闷。我是直接拼的SQL
if(mysql_num_rows($result)<1){
$dsql->SetQuery($query2);
}else{
$dsql->SetQuery($query);
}