【发布时间】:2014-12-20 14:16:03
【问题描述】:
我认为标题很混乱,我会尽量解释清楚。假设我有一个相当大的搜索帖子的查询,如下所示:
$posts = Post::select('...')
->leftJoin('...')
->leftJoin('...')
->where('...')
->orWhere('...')
->orderBy('...')
->orderBy('...')
->groupBy('...')
->with('...')
->paginate(8);
如何拆分此查询?例如:
$posts = Post::select('...')
->leftJoin('...')
->leftJoin('...')
$posts->where('...')
->orWhere('...');
$posts->orderBy('...')
->orderBy('...')
->groupBy('...');
$posts->with('...')
->paginate(8);
我正在使用 Laravel 4.2,我尝试了几件事(包括 this post),但我无法让它工作。我需要这个来搜索和过滤帖子。
【问题讨论】:
-
你能发布你正在使用的实际代码吗?你遇到了什么错误?
标签: php mysql laravel split eloquent