0
我有一个温度列表,每n分钟记录一次。我想获取特定日期的最小ID和最大ID。 $listDate
是数组中的日期列表。例如。Laravel对集合的雄辩结果
public getTemperature() {
$listDate = ['2016-12-08','2016-12-09','2016-12-10','2016-12-11'];
foreach($listDate as $date) {
$getId = array();
$getId[] = $this->selectRaw('MIN(`id`) as min, MAX(`id`) as max')
->where('created_at', '>=', $date. ' 00:00:00')
->where('created_at', '<=', $date. ' 23:59:59')
->get();
}
return $getId;
}
我希望它返回一个收藏这样
['min' => 1123, 'max' => 1345],
['min' => 1349, 'max' => 1567],
['min' => 1589, 'max' => 1612],
['min' => 1624, 'max' => 1655],