下面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語句轉成TP5的詳細內容。更多資訊請關注PHP中文網其他相關文章!