
教你如何把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语句转成TP5的详细内容,
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)