zoukankan      html  css  js  c++  java
  • 灵动标签内sql语句调用

    本节来介绍帝国cms中,灵动标签中如何写数据库调用我们所要的信息。方便一些没有学习过数据库的朋友

    转载请注明出处:谢寒的博客

    灵动标签默认的语法

    [e:loop={栏目ID/专题ID,显示条数,操作类型,只显示有标题图片,附加SQL条件,显示排序}]
    模板代码内容
    [/e:loop]

    案例1

    代码:

    [e:loop={'select title,titleurl,titlepic from [!db.pre!]ecms_news where classid in(46,47,51) and isgood=1,0,24,0}]

    解释:

    select title,titleurl,titlepic  意为调出:数据表内容的title titleul titlepic字段。

    from [!db.pre!]ecms_news  意从数据表为ecms_news 的数据表中调出信息,[!db.pre!]是数据表前缀变量,帝国默认的数据表前缀为phome,也就是从phome_ecms_news 中调出信息的意思。

    where classid in(46,47,51) 的意思为从栏目id为46,47,51栏目中调出信息,也就是选择条件

    and isgood=1 进一步的选择条件,选择其中一级推荐的内容。

    所以总结的意思就是从数据库的[!db.pre!]ecms_news数据表中调用出栏目id为46,48,51并且推荐等级为的1一级推荐的内容字段,包括:title,titleurl,titlepic

    举一反三

    多表信息调用

    [e:loop={'select title,titleurl,titlepic from [!db.pre!]ecms_news where classid in(46,47,51) and isgood=1 Union All select title,titleurl,titlepic from [!db.pre!]ecms_download',0,24,0}]

    Union 是链接符 意思为调用前面[!db.pre!]ecms_news 数据表内的,还调用下载数据表(ecms_download)内的内容

    这里有一个万能的调用方式为

    [e:loop={'select * from [!db.pre!]ecms_news where classid in(46,47,51) and isgood=1,0,24,0}]

    意思为可调用数据表(ecms_news)栏目(46,47,51)下的所有字段。

    可在调用方式中加附加条件,

    可指定按相应的字段排序:order by id desc

    帝国的灵动标签功能非常丰富,也不是一时半会儿能够完全讲清楚,学习者要多加钻研和联系,掌握这个标签,帝国的整套功能,也就能轻松驾驭了

  • 相关阅读:
    Apache ServiceComb Pack 微服务分布式数据最终一致性解决方案
    EF core 性能调优
    Entity Framework Core Query Types
    Using the Repository and Unit Of Work Pattern in .net core
    CENTOS 7 下安装 REDIS 5.0.6 完整步骤
    MySQL InnoDB 群集–在Windows上设置InnoDB群集
    RFM客户价值分类
    修改meta标签
    $.Deferred 使用 (支持jQuery1.5版本以上)
    error: Unexpected console statement (no-console) 解决办法
  • 原文地址:https://www.cnblogs.com/officexie/p/3170995.html
Copyright © 2011-2022 走看看