信息发布→ 登录 注册 退出

教你如何把SQL语句转成TP5

发布时间:2021-11-19

点击量:

下面thinkphp框架教程栏目将给大家简单介绍下如何把sql语句转成tp5,希望对需要的朋友有所帮助!

教你如何把SQL语句转成TP5?

具体问题描述:

求大神帮我把这段原生SQL语句转成TP5的谢谢!就是Db::('name')->这种链式操作的

'select a.id, a.title,a.create_time,a.is_solve,count(b.qid) as answer_count from fa_question a,fa_answer b where a.id=b.qid and a.is_solve=0 group by b.qid order by answer_count DESC LIMIT 6';

实现方法:

Db::table(['fa_question '=>'a','think_role'=>'b'])
    ->field('a.id, a.title, a.create_time, a.is_solve, count(b.qid) as answer_count)
    ->where(' a.id=b.qid and a.is_solve=0')
    ->group('b.qid')
    ->order('answer_count desc')
    ->limit(6)
    ->select()

附上手册,多看看手册https://www.kancloud.cn/manual/thinkphp5/135180

标签:# sql  # thinkphp  # https  # 转成  # 链式  # 我把  # 这段  # 大神  # 多看  # 将给  # 教你如何  # aliyucs  # keji  
在线客服
服务热线

服务热线

4008888355

微信咨询
二维码
返回顶部
×二维码

截屏,微信识别二维码

打开微信

微信号已复制,请打开微信添加咨询详情!