国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > CMS > 帝國Empire > 正文

帝國CMS靈動標簽調用多表多模型文章信息的寫法

2024-08-28 12:23:13
字體:
來源:轉載
供稿:網友

 要提高這條語句在頁面中的性能 博主將這個片段寫入了自定義頁面

 
這樣就能在需要的頁面 區域調用出來 而不需要時時訪問數據庫
大約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']); 真實下載地址的分割
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 莱州市| 乾安县| 北海市| 金乡县| 昌江| 大新县| 潢川县| 搜索| 六安市| 高尔夫| 安平县| 祁门县| 南平市| 丹棱县| 牟定县| 荃湾区| 马龙县| 株洲县| 盐山县| 龙州县| 金湖县| 泾阳县| 土默特左旗| 仙居县| 平阴县| 南充市| 措勤县| 涞源县| 泗洪县| 巴林左旗| 新河县| 神池县| 齐齐哈尔市| 绵竹市| 溧水县| 额尔古纳市| 祁东县| 台前县| 北票市| 阳西县| 汉阴县|