早安,我有这样的代码
$anfragens_temp=\App\OrdersStatus::select('orders_statuses.anfrageid','orders_statuses.datum','orders_statuses.stid_neu','credit_orders.partner_id','credit_orders.kreditbetrag','credit_orders.brutto_kreditbetrag')
->LeftJoin('credit_orders', 'credit_orders.id', '=', orders_statuses.anfrageid')
->whereIn('orders_statuses.stid_neu', $main_array_stat )
->whereDate( 'credit_orders.date' ,'>=',$dt_von)
->whereDate('credit_orders.date' ,'<=',$dt_bis)
->whereHas('orders', function ($query)use($conditions2) {
$query->whereIn('partner_id', $conditions2 );
})-> get();
$anfragens_temp=collect($anfragens_temp);
$anfragens_temp=$anfragens_temp->whereIn('stid_neu',array(1,12,31));
$result=$anfragens_temp->groupBy('anfrageid');
foreach($result as $k=>$v){
$semi_result=$anfragens_temp->where('anfrageid',$v[0]->anfrageid)->max('datum');
$resu = $anfragens_temp->where('anfrageid',$v[0]->anfrageid)->where('datum', $semi_result)->first();
$max[$resu->partner_id][$k]['stid_neu']=$resu->stid_neu;
$max[$resu->partner_id][$k]['summ']=$resu->kreditbetrag;
$max[$resu->partner_id][$k]['brutto_kreditbetrag']=$resu->brutto_kreditbetrag;
}
请帮助我在一次雄辩的查询中转换其余的php / 问题是,如果我设置大数据时间段,那么此附加的计数代码将运行很长时间,并且查询生成器的运行速度要快得多。 )非常感谢大家