多表模糊查询后,获得的内容数量如何传到分页中

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

  • #7 · 2021-04-07 22:28:24
    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
    满意答案
    K大帅 补充个debug的截图

  • #9 · 2021-04-08 10:02:40
    @无:!!!!!!!!!!!!!

迅睿系统漏洞

IP138查询
IP138查询(2026-09-02)
转换本地ip地址作用。后台安装/启用插件 Ip_ysb进入「应用 →...
GeoSeo工具箱
GeoSeo工具箱(2026-09-02)
优化城市落地页全选
GEO系统
GEO系统(2026-09-02)
支持最新的ai优化算法 后台增加可控制的站点运营管理
外贸多语言建站
外贸多语言建站(2026-09-02)
修正重复数据传参 增加CLI模式说明
开发者工具
开发者工具(2026-09-02)
增加插件脚手架 增加控制器编写辅助
用户系统
用户系统(2026-09-02)
增强用户列表安全验证,防止个人信息泄露
节日灯笼
节日灯笼(2026-09-01)
新增顶部节日横幅 Banner ,祝福语文字 新增节日特效:Can...
GeoSeo收录宝
GeoSeo收录宝(2026-09-01)
升级 ai智能发布功能 升级 支持8国语言后端设置和前端输出功能 ...