我正在重写一些
PHP / MysqL以与Laravel一起工作.我想做的一件事是让数据库查询更简洁
with the Fluent Query Builder,但我有点迷失:
SELECT p.post_text,p.bbcode_uid,u.username,t.forum_id,t.topic_title,t.topic_time,t.topic_id,t.topic_poster FROM PHPbb_topics t,PHPbb_posts p,PHPbb_users u WHERE t.forum_id = 9 AND p.post_id = t.topic_first_post_id AND u.user_id = t.topic_poster ORDER BY t.topic_time DESC LIMIT 10
我怎么能重写这个来使用Fluent Query Builder语法?
没有测试,但这是一个开始
原文链接:https://www.f2er.com/laravel/138768.htmlreturn DB::table('PHPbb_topics') ->join('PHPbb_posts','PHPbb_topics.topic_first_post_id','=','PHPbb_posts.post_id') ->join('PHPbb_users','PHPbb_topics.topic_poster','PHPbb_users.user_id') ->order_by('topic_time','desc') ->take(10) ->get(array( 'post_text','bbcode_uid','username','forum_id','topic_title','topic_time','topic_id','topic_poster' ));