我正在尝试写一个特定的查询,但是我失败了,我正在寻求帮助
以下是我想做的事
选择created_at本月之前的所有项目(7月、6月、.),并选择本月期间创建的前3项
这就是我现在所拥有的。我试过很多次了,但我找不出正确的“哪里”案件
$offertes = DB::table('offertes')
->select('*')
->where('receiver_id', $user_id)
...
->orderby('seen')
->orderby('created_at','desc')
->get();发布于 2016-08-07 09:51:45
像这样的事情应该有效:
$time = new Carbon\Carbon('first day of this month'); // Get first day of the month.
$time->setTime(0, 0, 0); // Set time to 00:00:00.
....
->where('created_at', '<', $time)
->where(function($q) {
$q->where('created_at', '>', $time)
->orderby('created_at','asc')
->take(3)
})
->get;https://stackoverflow.com/questions/38812798
复制相似问题