Pursuing a dream common to use simple sql tag

1 Home is a direct call id column content of 2

{dede:sql sql="select content from dede_arctype where id=2"} 
[field:content function=cn_substr(Html2Text(@me),600)/] 
{/dede:sql} 

2, call the list of articles

{dede:sql sql="select * From dede_archives limit 10"} 
<li>·<a href='[field:id runphp='yes'] $id=@me;@me='';$url=GetOneArchive($id);@me=$url['arcurl'];[/field:id]'>[field:title/]</a><img src="[field:litpic/]" alt="[field:title function='html2text(@me)'/]" title="[field:title function='html2text(@me)'/]"/></li> 
{/dede:sql} 

3, php form to call a list of articles (It should be in the system parameters - additional options to remove the disabled php)

{dede:php}
$dsql->SetQuery("SELECT * FROM dede_archives limit 10");
$dsql->Execute();
while($arr = $dsql->getArray()){
$arcurl = GetOneArchive($arr['id']);
$title = GetOneArchive($arr['id']);
echo '<li>·<a href="'.$arcurl['arcurl'].'">'.$title['title'].'</a></li>';
}
{/dede:php}

4, call the specified Field Description

{dede:sql sql='Select description from dede_arctype where id=28'}
             [field:description/]
 {/dede:sql}

5, sql calls more specified columns, specify a label (flag), the article

{dede:sql sql="select a.id,a.pubdate,a.litpic,a.title,t.id,t.typedir from  #@__archives as a left join #@__arctype as t on a.typeid=t.id where a.typeid in(69,70,71,72,73,74) and a.flag like '%p%' order by pubdate desc limit 0,4"} 
            <div class="ppfk_cellk L"> 
                  <div class="ppfk_cell"> 
                    <div class="ppfk_cellpic bord"><a href="[field:typedir runphp='yes']@me=str_replace('{cmspath}','','@me');[/field:typedir]/[field:id/].html"><img src='[field:litpic/]' border='0' width='120' height='120' alt='[field:title/]'/></a></div> 
                    <div class=" ppfk_wen"><a href="[field:typedir runphp='yes']@me=str_replace('{cmspath}','','@me');[/field:typedir]/[field:id/].html" title="[field:title/]">[field:title/]</a></div></div></div> 
{/dede:sql}

In fact, in addition to the above example, the system Dede, and I can be free to use SQL statements to weave dreams with labels more personalized calls. Their basic reference format:

code show as below:

{dede:sql sql="select 字段 From 表名称 where 条件语句"} 
[field:字段名/] 
{/dede:sql} 
Published 10 original articles · won praise 0 · Views 99

Guess you like

Origin blog.csdn.net/lichuang214/article/details/104783201