当前位置: 首页 > 新闻动态 > 技术教程

教你如何把SQL语句转成TP5

作者:藏色散人 浏览: 发布日期:2021-11-19
[导读]:​下面thinkphp框架教程栏目将给大家简单介绍下如何把SQL语句转成TP5,希望对需要的朋友有所帮助!

下面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

免责声明:转载请注明出处:http://sczxchw.cn/news/37196.html

扫一扫高效沟通

多一份参考总有益处

免费领取网站策划SEO优化策划方案

请填写下方表单,我们会尽快与您联系
感谢您的咨询,我们会尽快给您回复!