帝国CMS灵动标签调用多表多模型文章信息的写法

 要提高这条语句在页面中的性能 博主将这个片段写入了自定义页面

这样就能在需要的页面 区域调用出来 而不需要时时访问数据库
大约10分钟刷新一次 降低了 大数据下访客每次访问时都要查询多次数据库的巨大压力
帝国7的包含自定义页面可以这么写 
 
<?php require(ECMS_PATH.’page1.html’);?> 
注意:page1.html在根目录。若在t目录则写成“t/page1.html”
 
或 
 
[includefile]’../../page1.html'[/includefile]  注意:开启“[includefile]”标签   后台–模板–标签–标签管理–修改(选择对应标签)–开启
 
———————————————————————-
1、调用多模型的最新文章
[e:loop={‘select * from ( 
select id,classid,titleurl,filename,title,newstime,titlepic from [!db.pre!]ecms_movie where newstime union 
select id,classid,titleurl,filename,title,newstime,titlepic from [!db.pre!]ecms_news where newstime union 
select id,classid,titleurl,filename,title,newstime,titlepic from [!db.pre!]ecms_photo where newstime union 
select id,classid,titleurl,filename,title,newstime,titlepic from [!db.pre!]ecms_flash where newstime union 
select id,classid,titleurl,filename,title,newstime,titlepic from [!db.pre!]ecms_article where newstime
) a order by newstime desc limit 10′,10,24,1}] 
<a href=<?=$bqsr[‘titleurl’]?> target=_blank><?=$bqr[‘title’]?></a> <br>
[/e:loop]
 
帝国CMS多表调用最新信息,该演示代码为默认数据表下全站最新10条图片信息,自己根据需求可以附加条件,实现全站点击,全站头条,全站推荐等等.
 
注释:以上多个模型用“Union”连接调用
 
若只调用图片:要加ispic=1条件
举例:
[e:loop={‘select * from (
select id,classid,titleurl,filename,title,newstime,titlepic from [!db.pre!]ecms_news where newstime and ispic=1 union
select id,classid,titleurl,filename,title,newstime,titlepic from [!db.pre!]ecms_photo where newstime and ispic=1 union
select id,classid,titleurl,filename,title,newstime,titlepic from [!db.pre!]ecms_flash where newstime and ispic=1 union
select id,classid,titleurl,filename,title,newstime,titlepic from [!db.pre!]ecms_article where newstime and ispic=1) a order by newstime desc limit 10′,10,24,1}]
<a href=<?=$bqsr[‘titleurl’]?> target=_blank><img src=<?=$bqr[‘titlepic’]?>/><?=$bqr[‘title’]?></a> <br>
[/e:loop] 
 
 
———————————————————————————
2、调用多模型的最新文章
[e:loop={‘select title,titleurl,titlepic from [!db.pre!]ecms_photo Union All select title,titleurl,titlepic from [!db.pre!]ecms_download Union All 
select title,titleurl,titlepic from [!db.pre!]ecms_news’,0,24,0}]
<a href=<?=$bqsr[‘titleurl’]?> target=_blank><?=$bqr[‘title’]?></a> <br>
[/e:loop]
 
注释:以上调用的是(图片模型:photo、下载模型:download、新闻模型:news)三个模型的文章
       三个模型用“Union All”连接调用
 
若指定栏目用:where classid in(46,47,51),
若调用推荐在其后追加:and isgood=1,
若指定调用条数在其后追加:limit 10
 
举例:
多表调用 同时显示“标题”所在的“栏目名称”和“链接” 及以“点击排行”
[e:loop={select titleurl,title,onclick,classid from phome_ecms_news union all select titleurl,title,onclick,classid from phome_ecms_article order by onclick desc limit 10,1,24,0}]
<LI><A href=<?=$bqsr[classurl]?> target=_blank><?=$bqsr[classname]?></A> | <A href=<?=$bqsr[titleurl]?> target=_blank><?=$bqr[title]?></A></LI>
[/e:loop]
 
———————————————————————————
3、多表联合查询“主、副”表调用文章
[e:loop={‘select * from (
(select id,classid,title,titleurl,titlepic,newstime from [!db.pre!]ecms_download limit 3 )
Union All
(select id,classid,title,titleurl,titlepic,newstime from [!db.pre!]ecms_movie limit 3)
)  as A  order by newstime desc ‘,0,24,0}]
<?php
$fb=$empire->fetch1(select * 
from 
(
(select id,classid,downpath from {$dbtbpre}ecms_download_data_1 where id=’$bqr[id]’ and classid=’$bqr[classid]’)
 
Union All
(select id,classid,downpath from {$dbtbpre}ecms_movie_data_1 where id=’$bqr[id]’ and classid=’$bqr[classid]’)
 
) as A);
$olurl=explode(‘::::::’,$fb[‘downpath’]);
?>
<li><a href=<?=$bqsr[‘titleurl’]?>><img src=<?=$bqr[‘titlepic’]?> alt=<?=$bqr[‘title’]?>></a>
<div><h3 class=title><?=$bqr[‘title’]?></h3><p>下载地址:<?=$olurl[1]?></p></div>
</li>
[/e:loop]
 
注释:以上调用的是(下载模型:download、电影模型:movie)两个模型,并电影副表中下载地址“downpath”(电影副表下载地址未调出,因为里面没有东西)
       两个模型用“Union All”连接调用
      $olurl=explode(‘::::::’,$fb[‘downpath’]); 真实下载地址的分割
 
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!
8. 精力有限,不少源码未能详细测试(解密),不能分辨部分源码是病毒还是误报,所以没有进行任何修改,大家使用前请进行甄别
9.本站默认解压密码为:www.sudo1.com
本站提供的一切软件、教程和内容信息仅限用于学习和研究目的。
不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。
本站信息来自网络收集整理,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑或手机中彻底删除上述内容。
如果您喜欢该程序和内容,请支持正版,购买注册,得到更好的正版服务。
我们非常重视版权问题,如有侵权请邮件与我们联系处理。敬请谅解!

云资源网 » 帝国CMS灵动标签调用多表多模型文章信息的写法

常见问题FAQ

免费下载或者VIP会员专享资源能否直接商用?
本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。更多说明请参考 VIP介绍。
提示下载完但解压或打开不了?
最常见的情况是下载不完整: 可对比下载完压缩包的与网盘上的容量,若小于网盘提示的容量则是这个原因。这是浏览器下载的bug,建议用百度网盘软件或迅雷下载。 若排除这种情况,可在对应资源底部留言,或 联络我们.。
你们有qq群吗怎么加入?
当然有的,如果你是帝国cms、易优cms、和pbootcms系统的爱好者你可以加入我们的QQ千人交流群https://www.sudo1.com/page-qun.html。
  • 会员数(个)
  • 12310资源数(个)
  •        
  • 资源(G)
  •        
  • 今日下载
  • 1506稳定运行(天)

提供最优质的资源集合

立即查看 了解详情