业务经理

微信扫描以上二维码

028-61286886

技术咨询

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

迅睿框架 更新 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
    @无:!!!!!!!!!!!!!

迅睿系统漏洞

外贸多语言建站
外贸多语言建站(2026-10-30)
修正对百度编辑器提取支持
AI文章生成器
AI文章生成器(2026-10-29)
任务插图设置数量
Bing站长数据
Bing站长数据(2026-10-29)
根据BING接口调整菜单 各个页面数据支持点击查看详情
按字段付费
按字段付费(2026-10-29)
按字段付费用于模块的字段设置一定的价格,当用户购买了此内容的字段时才...
泛解析站群系统
泛解析站群系统(2026-10-29)
AI队列增加清空按钮 表单提示语收敛 目录模式不接管主域名模板
账号注销
账号注销(2026-10-29)
用于用户中心的注销账号申请,后台审核通过后注销此账号。后台统一管理注...
邮件群发
邮件群发(2026-10-28)
修改模板的命名
自定义收款/捐款
自定义收款/捐款(2026-10-28)
自定义收款或捐款插件可以让用户快速创建付款或者捐款功能
CMS内容批量修改
CMS内容批量修改(2026-10-28)
后台批量修改文章内容的指定字段在插件后台可以任意指定字段
全站模块搜索
全站模块搜索(2026-10-28)
实现全模块一次性搜索内容,一键搜索全站内容精准搜索全部模块: