鍍金池/ 問答/PHP  數(shù)據(jù)庫/ 求幫我把這段原生SQL語句轉(zhuǎn)成TP5的謝謝!

求幫我把這段原生SQL語句轉(zhuǎn)成TP5的謝謝!

求大神幫我把這段原生SQL語句轉(zhuǎn)成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/manua...

2018年1月19日 10:44