联系官方销售客服

1835022288

028-61286886

迅睿框架 版主:迅睿框架研发组
多表模糊查询后,获得的内容数量如何传到分页中
类型:迅睿CMS 更新时间:2021-04-08 10:02:40

新手求教,大神们,多表模糊查询后,获得的内容数量如何传到分页中?

数据库中测试的查询:

select sum(a.b) as num from (
select count("title,keywords,inputtime,description,url,content") as b from dr_1_news where title like "%出租%" OR keywords like "%出租%" OR content like "%出租%"
union all
select count("title,keywords,inputtime,description,url,content") as b from dr_1_qcp where title like "%出租%" OR keywords like "%出租%" OR content like "%出租%"
union all
select count("title,keywords,inputtime,description,url,content") as b from dr_1_zhuanr  where title like "%出租%" OR keywords like "%出租%" OR content like "%出租%"
union all
select count("title,keywords,inputtime,description,url,content") as b from dr_1_tix where title like "%出租%" OR keywords like "%出租%" OR content like "%出租%"
union all
select count("title,keywords,inputtime,description,url,content") as b from dr_1_zhin where title like "%出租%" OR keywords like "%出租%" OR content like "%出租%"
union all
select count("title,keywords,inputtime,description,url,content") as b from dr_1_wend where title like "%出租%" OR keywords like "%出租%" OR content like "%出租%"
) as a

查询结果是13条

{xunruicms_img_title}



目前查询到的数量是 6个模型的数量,如何传入从所有模型中查询内容的数量?

页面执行查询语句

select * from (select title,keywords,inputtime,description,url,content from dr_1_news where title like "%出租%" OR keywords like "%出租%" OR content like "%出租%"
union all
select title,keywords,inputtime,description,url,content from dr_1_qcp where title like "%出租%" OR keywords like "%出租%" OR content like "%出租%"
union all
select title,keywords,inputtime,description,url,content from dr_1_zhuanr where title like "%出租%" OR keywords like "%出租%" OR  content like "%出租%"
union all
select title,keywords,inputtime,description,url,content from dr_1_tix where title like "%出租%" OR keywords like "%出租%" OR  content like "%出租%"
union all
select title,keywords,inputtime,description,url,content from dr_1_zhin where title like "%出租%" OR keywords like "%出租%" OR  content like "%出租%"
union all
select title,keywords,inputtime,description,url,content from dr_1_wend where title like "%出租%" OR keywords like "%出租%" OR  content like "%出租%") AS a

{xunruicms_img_title}

回帖
  • K大帅
    #1楼    K大帅
    2021-04-07 21:22:59
    Chrome 0
    为啥不直接用 多模块内容循环呢?参考文档:《多模块内容循环》
  • K大帅
    #2楼    K大帅
    2021-04-07 21:24:08
    Chrome 0
    {php $query=urlencode('sql语句');}
    {sql sql='$query'}
    {$t.字段}
    {/sql}
    {$debug}
    {$pages}
  • 无
    #3楼    无
    2021-04-07 22:14:46
    Chrome 0
    K大帅 就是用的这查询的,但是多表查询出来后,组成一个新的临时表,系统自带的分页只获取的模型数量,
    {php $query=urlencode('sql语句');}
    {sql sql='$query'}
    {$t.字段}
    {/sql}
    {$debug}
    {$pages}
  • 二开/定制/使用解答专家
    #4楼    二开/定制/使用解答专家
    2021-04-07 22:17:56
    Chrome 0
    太复杂了,完全看不懂
  • K大帅
    #5楼    K大帅
    2021-04-07 22:22:00
    小米手机 0
    把解析后结果和debug发出来呀,怎么会组成新表呢
  • 无
    #6楼    无
    2021-04-07 22:24:40
    Chrome 0
    二开/定制/使用解答专家 就是从这6个模型中 查询标题、关键字、内容中包含‘车牌’ 这个标签的文章,然后把查询内容的总数传到分页中,然后进行分页,目前的分页显示的是6个模型的数量,不是所匹配的内容总量

  • 无
    #7楼    无
    2021-04-07 22:28:24
    Chrome 0
    K大帅

    debug
    标签解析:{list action=sql sql='select+%2A+from+%28select+title%2Ckeywords%2Cinputtime%2Cdescription%2Curl%2Ccontent+from+dr_1_news+where+title+like+%22%25%E5%87%BA%E7%A7%9F%25%22+OR+keywords+like+%22%25%E5%87%BA%E7%A7%9F%25%22+OR+content+like+%22%25%E5%87%BA%E7%A7%9F%25%22%0Aunion+all%0Aselect+title%2Ckeywords%2Cinputtime%2Cdescription%2Curl%2Ccontent+from+dr_1_qcp+where+title+like+%22%25%E5%87%BA%E7%A7%9F%25%22+OR+keywords+like+%22%25%E5%87%BA%E7%A7%9F%25%22+OR+content+like+%22%25%E5%87%BA%E7%A7%9F%25%22%0Aunion+all%0Aselect+title%2Ckeywords%2Cinputtime%2Cdescription%2Curl%2Ccontent+from+dr_1_zhuanr+where+title+like+%22%25%E5%87%BA%E7%A7%9F%25%22+OR+keywords+like+%22%25%E5%87%BA%E7%A7%9F%25%22+OR++content+like+%22%25%E5%87%BA%E7%A7%9F%25%22%0Aunion+all%0Aselect+title%2Ckeywords%2Cinputtime%2Cdescription%2Curl%2Ccontent+from+dr_1_tix+where+title+like+%22%25%E5%87%BA%E7%A7%9F%25%22+OR+keywords+like+%22%25%E5%87%BA%E7%A7%9F%25%22+OR++content+like+%22%25%E5%87%BA%E7%A7%9F%25%22%0Aunion+all%0Aselect+title%2Ckeywords%2Cinputtime%2Cdescription%2Curl%2Ccontent+from+dr_1_zhin+where+title+like+%22%25%E5%87%BA%E7%A7%9F%25%22+OR+keywords+like+%22%25%E5%87%BA%E7%A7%9F%25%22+OR++content+like+%22%25%E5%87%BA%E7%A7%9F%25%22%0Aunion+all%0Aselect+title%2Ckeywords%2Cinputtime%2Cdescription%2Curl%2Ccontent+from+dr_1_wend+where+title+like+%22%25%E5%87%BA%E7%A7%9F%25%22+OR+keywords+like+%22%25%E5%87%BA%E7%A7%9F%25%22+OR++content+like+%22%25%E5%87%BA%E7%A7%9F%25%22%29+AS+a' order=hits page=1 pagesize=5 urlrule=index.php?s=tag&c=home&m=index&name=chepai&module=&type=&page=[page]}查询解析: select * from (select title,keywords,inputtime,description,url,content from dr_1_news where title like "%出租%" OR keywords like "%出租%" OR content like "%出租%"
    union all
    select title,keywords,inputtime,description,url,content from dr_1_qcp where title like "%出租%" OR keywords like "%出租%" OR content like "%出租%"
    union all
    select title,keywords,inputtime,description,url,content from dr_1_zhuanr where title like "%出租%" OR keywords like "%出租%" OR  content like "%出租%"
    union all
    select title,keywords,inputtime,description,url,content from dr_1_tix where title like "%出租%" OR keywords like "%出租%" OR  content like "%出租%"
    union all
    select title,keywords,inputtime,description,url,content from dr_1_zhin where title like "%出租%" OR keywords like "%出租%" OR  content like "%出租%"
    union all
    select title,keywords,inputtime,description,url,content from dr_1_wend where title like "%出租%" OR keywords like "%出租%" OR  content like "%出租%") AS a LIMIT 0,5开发模式:已开启数据缓存:开发者模式下缓存无效总记录数:6分页功能:已开启当前页码:1总页数量:2每页数量:5分页地址:index.php?s=tag&c=home&m=index&name=chepai&module=&type=&page=页码可用字段:title、keywords、inputtime、description、url、content
  • 无
    #8楼    无
    2021-04-07 22:31:19
    Chrome 0
    K大帅 补充个debug的截图

    满意答案
  • 无
    #9楼    无
    2021-04-08 10:02:40
    Chrome 0
    @无:!!!!!!!!!!!!!