phpcms调用热门第一种:
{pc:get sql="SELECT * FROM `v9_news` a, `v9_hits` p WHERE a.catid=$catid and a.status=99 and a.inputtime > UNIX_TIMESTAMP()-7*3600*24 and CONCAT( 'c-1-', a.id ) = p.hitsid ORDER BY p.weekviews DESC" num="15"}{loop $data $r} <font title="{date(" y-m-d',="" $r[inputtime])}"="" style="margin: 0px; padding: 0px; word-break: break-all; overflow-wrap: break-word;">{date('d', $r[inputtime])}日 {str_cut($r[title],38)} {/loop}{/pc}
其中 c-1-中的1代表MODELID 请更换成你自己的模型ID ,经测试此方法超占MYSQL资源
phpcms调用热门第二种:
SELECT a.title,a.url FROM v9_news a,v9_hits b WHERE a.id = substr(b.hitsid,5) AND status = 99 ORDER BY b.views DESC
注意:substr(b.hitsid,5)的意思是截取v9_hits表里hitsid字段值第5个字符起至结束,请按实际情况修改,如果你的站点ID是两位数,那么这里你要从第6个字符开始,完美一点再加个 a.catid=b.catid