$lastYearNums = $apply
->field(['CONCAT(date_format(from_unixtime(create_time),\'%Y\'),"-",date_format(from_unixtime(create_time),\'%m\'))' =>'yearmonth','count("id") as total'])
->where('(date_format(from_unixtime(create_time),\'%Y\')>'.$yearStart.' or (date_format(from_unixtime(create_time),\'%Y\')='.$yearStart.' and date_format(from_unixtime(create_time),\'%m\')>'.$monthStart.'))')
->group('yearmonth')
->select();
dump($lastYearNums->toArray());exit;
$arrYearMonth = [];
$arrMonthTotal = [];
foreach ($lastYearNums as $key => $itemNums){
array_push($arrYearMonth,date('Y-m',strtotime($itemNums['yearmonth'])));
array_push($arrMonthTotal,$itemNums['total']);
}
查询结果展示: