精品国语人妻色乱码二区,免费乱理伦片在线观看2018,日韩精品视频在线播放,高潮无码又爽又刺激视频在线

<source id="8jepl"><menu id="8jepl"></menu></source>
    <source id="8jepl"><menu id="8jepl"></menu></source>
    <rp id="8jepl"><mark id="8jepl"><label id="8jepl"></label></mark></rp>
          <source id="8jepl"><menu id="8jepl"><label id="8jepl"></label></menu></source>
          <source id="8jepl"></source>
              <source id="8jepl"></source>
                <video id="8jepl"><menu id="8jepl"></menu></video>
                0712-2888027 189-8648-0214
                微信公眾號

                孝感風(fēng)信網(wǎng)絡(luò)科技有限公司微信公眾號

                當(dāng)前位置:主頁 > 技術(shù)支持 > PHPCMS > PHPCMS中PC:GET標(biāo)簽完全使用指南

                PHPCMS中PC:GET標(biāo)簽完全使用指南

                時(shí)間:2016-07-20來源:風(fēng)信官網(wǎng) 點(diǎn)擊: 1100次
                一、get 標(biāo)簽概述

                通俗來講,get 標(biāo)簽是Phpcms定義的能直接調(diào)用數(shù)據(jù)庫里面內(nèi)容的簡單化、友好化代碼,她可調(diào)用本系統(tǒng)和外部數(shù)據(jù),只有你對SQL有一定的了解,她就是你的絕世好劍!也就是適合熟悉SQL語句的人使用。有了她,我們打造個(gè)性化的網(wǎng)站,能非常方便的調(diào)用出數(shù)據(jù)庫里面指定的內(nèi)容。通過條件限制,我們可以調(diào)用出不同條件下的不同數(shù)據(jù)。

                二、get標(biāo)簽樣式

                {get dbsource=" " sql=" "}

                {/get}

                三、get 標(biāo)簽語法

                1.get標(biāo)簽屬性值必須用雙引號括起來( " " )。
                例如:

                {get sql=" " /}

                2.get標(biāo)簽必須含有結(jié)束標(biāo)記,即正確get標(biāo)簽必須是成對出現(xiàn):整個(gè)Get標(biāo)簽含有結(jié)束標(biāo)記“ {/get}”,或者是“/”。

                3.get標(biāo)簽里面含有的變量,數(shù)組和函數(shù)必須用“{}”包括。
                例如:

                {str_cut($r[title], 50)}
                {$r[url]}

                4.get標(biāo)簽 sql語句中條數(shù)限制。( rows=" " )
                例如:顯示10條信息

                {get sql=" " rows="10"}
                {/get}

                5.get標(biāo)簽 sql語句中條件限制。( where )
                例如:調(diào)用欄目ID為1的信息

                {get sql="select * from phpcms_content where catid=1"}
                標(biāo)題:{$r[title]} URL:{$r[url]}  
                {/get}

                6.get標(biāo)簽 sql語句中排序。( order by )
                例如:按更新日期降序(desc)排列

                {get sql="select * from phpcms_content order by updatetime desc" }
                {$r[title} URL:{$r[url]}
                {/get}

                7.get標(biāo)簽里面嵌套php函數(shù)。(可以參考上面的第3點(diǎn))
                例如:格式化輸出時(shí)間戳

                {date('Y-m-d', $r[updatetime])}

                8.本系統(tǒng)數(shù)據(jù)調(diào)用(當(dāng)前數(shù)據(jù)庫調(diào)用)

                {get sql=""}
                {/get}

                或者

                {get sql="" return="r"}
                {/get}

                9.本系統(tǒng)數(shù)據(jù)調(diào)用10條

                {get sql="" rows="10"}
                {/get}

                10.同一個(gè)數(shù)據(jù)庫帳號的不同數(shù)據(jù)庫調(diào)用

                {get dbname="" sql="" }
                {/get}

                11.不同數(shù)據(jù)庫帳號調(diào)用(不同數(shù)據(jù)源調(diào)用)

                {get dbsource="" sql=""}
                {/get}

                12.不同數(shù)據(jù)庫帳號的不同數(shù)據(jù)庫調(diào)用

                {get dbsource="" dbname="" sql="" }

                {/get}

                13.本系統(tǒng)數(shù)據(jù)調(diào)用,帶分頁

                {get sql=" " page="$page"}
                {/get}
                分頁:{$pages}

                14.本系統(tǒng)數(shù)據(jù)調(diào)用,自定義返回變量

                {get sql=" " return="v"}
                {$v[ ]}
                {/get}

                *get 標(biāo)簽參數(shù)完整剖析

                {get dbsource="數(shù)據(jù)源" dbname="數(shù)據(jù)庫" sql="SQL語句" rows="行數(shù)" return="返回變量名稱" page="$page"}
                輸出代碼(含返回變量值、數(shù)組、函數(shù)等)
                {/get}

                dbname="數(shù)據(jù)庫" -->
                (數(shù)據(jù)庫 在添加數(shù)據(jù)源的時(shí)候需要填寫的數(shù)據(jù)庫名)
                注:本系統(tǒng)調(diào)用(同一數(shù)據(jù)庫賬號,同一數(shù)據(jù)庫名)可以省略
                sql="SQL語句" -->
                SQL語句可以參考Mysql手冊,上面get 標(biāo)簽語法第4、5、6點(diǎn)和SQL語句剖析已經(jīng)提及要點(diǎn)
                注:此參數(shù)不可以省略
                rows="行數(shù)" -->
                行數(shù),例如顯示10條信息:rows="10"
                注:此參數(shù)可以省略
                return="返回變量名稱" -->
                參考get 標(biāo)簽語法第8點(diǎn)和第14點(diǎn)
                注:此參數(shù)可以省略
                page="$page" -->
                帶分頁
                注:此參數(shù)可以省略

                *SQL語句剖析

                sql="select 字段 from 表名 where 條件表達(dá)式 order by 字段 desc/asc"

                6條完整get 標(biāo)簽代碼示例

                1.調(diào)用本系統(tǒng)單條數(shù)據(jù),示例(調(diào)用ID為1的信息,標(biāo)題長度不超過25個(gè)漢字,顯示更新日期):

                {get sql="select * from phpcms_content where contentid=1" /}
                標(biāo)題:{str_cut($r[title], 50)} URL:{$r[url]} 更新日期:{date('Y-m-d', $r[updatetime])}

                2.調(diào)用本系統(tǒng)多條數(shù)據(jù),示例(調(diào)用欄目ID為1通過審核的10條信息,標(biāo)題長度不超過25個(gè)漢字,顯示更新日期):

                {get sql="select * from phpcms_content where catid=1 and status=99 order by updatetime desc" rows="10"}
                標(biāo)題:{str_cut($r[title], 50)} URL:{$r[url]} 更新日期:{date('Y-m-d', $r[updatetime])}
                {/get}

                3.帶分頁,示例(調(diào)用欄目ID為1通過審核的10條信息,標(biāo)題長度不超過25個(gè)漢字,顯示更新日期,帶分頁):

                {get sql="select * from phpcms_content where catid=1 and status=99 order by updatetime desc" rows="10" page="$page"}
                標(biāo)題:{str_cut($r[title], 50)} URL:{$r[url]} 更新日期:{date('Y-m-d', $r[updatetime])}
                {/get}
                分頁:{$pages}

                4.自定義返回變量,示例(調(diào)用欄目ID為1通過審核的10條信息,標(biāo)題長度不超過25個(gè)漢字,顯示更新日期,返回變量為 $v):

                {get sql="select * from phpcms_content where catid=1 and status=99 order by updatetime desc" rows="10" return="v"}
                標(biāo)題:{str_cut($v[title], 50)} URL:{$v[url]} 更新日期:{date('Y-m-d', $v[updatetime])}
                {/get}

                5.調(diào)用同一帳號下的其他數(shù)據(jù)庫,示例(調(diào)用數(shù)據(jù)庫為bbs,分類ID為1的10個(gè)最新主題,主題長度不超過25個(gè)漢字,顯示更新日期):

                {get dbname="bbs" sql="select * from cdb_threads where fid=1 order by dateline desc" rows="10"}
                主題:{str_cut($r[subject], 50)} URL:http://bbs.phpcms.cn/viewthread.php?tid={$r[tid]} 更新日期:{date('Y-m-d', $r[dateline])}
                {/get}

                6.調(diào)用外部數(shù)據(jù),示例(調(diào)用數(shù)據(jù)源為bbs,分類ID為1的10個(gè)最新主題,主題長度不超過25個(gè)漢字,顯示更新日期):

                {get dbsource="bbs" sql="select * from cdb_threads where fid=1 order by dateline desc" rows="10"}
                主題:{str_cut($r[subject], 50)} URL:http://bbs.phpcms.cn/viewthread.php?tid={$r[tid]} 更新日期:{date('Y-m-d', $r[dateline])}
                {/get}

                四、get 標(biāo)簽創(chuàng)建工具

                1、獲取get 標(biāo)簽代碼

                例如,剛才我們數(shù)據(jù)源選擇“本系統(tǒng)”,數(shù)據(jù)表選擇“內(nèi)容模型”,字段名我們顯示“ID、標(biāo)題、摘要、鏈接地址、發(fā)布時(shí)間”,條件選擇ID=1,排序按ID降序排序,勾選“是否分頁”,每頁顯示條數(shù)設(shè)置為“10條”,然后點(diǎn)擊“插入”

                我們就可以得到系統(tǒng)自動(dòng)生成的get 標(biāo)簽代碼,如下:

                {get sql="SELECT `contentid`,`title`,`description`,`url`,`inputtime` FROM `phpcms_content` WHERE `contentid` = '1' ORDER BY `contentid` DESC"rows="10" page="$page" }
                {$r[contentid]}
                {$r[title]}
                {$r[description]}
                {$r[url]}
                {$r[inputtime]}
                {/get}
                {$pages}

                分析如下:

                {get sql="SELECT `contentid`,`title`,`description`,`url`,`inputtime` FROM ` phpcms_content`" WHERE `contentid` = '1' ORDER BY   `contentid` DESC   rows="10"   page="$page" }
                //條件是ID=1,排序按ID降序排序,顯示10行,帶分頁

                {$r[contentid]}
                // ID

                {$r[title]}
                //標(biāo)題

                {$r[description]}
                //摘要

                {$r[url]}
                //鏈接地址

                {$r[inputtime]}
                //發(fā)布時(shí)間
                {/get}
                {$pages}
                //分頁

                2、將代碼插入到模板文件

                get 標(biāo)簽代碼如下:
                {get dbsource="discuz" sql="SELECT `author`,`subject`,`lastpost` FROM `cdb_threads` ORDER BY `lastpost` DESC" rows="3" }
                {$r[author]}
                {$r[subject]}
                {$r[lastpost]}
                {/get}

                更多網(wǎng)站公告

                在上面加入(稍加美化的get 標(biāo)簽代碼):

                論壇最新帖子

                {get dbsource="discuz" sql="SELECT `author`,`subject`,`lastpost` FROM `cdb_threads` ORDER BY `lastpost` DESC" rows="3" }
                ({$r[author]}){str_cut($r[subject], 22,"")} date:{date("Y-m-d",$r[lastpost])}

                {/get}
                熱門關(guān)鍵詞: PHPCMS GET標(biāo)簽
                欄目列表
                推薦內(nèi)容
                熱點(diǎn)內(nèi)容
                展開