通过SQL语句由组导致的组迭代

时间:2016-05-15 16:51:59

标签: php mysql sql loops

有没有办法迭代按select语句分组的组?

      $bidsInPeriod = DB::table('bids')
        ->select('bundle_id','owner_id','target','bid', DB::raw('count(*) as total'))
        ->where('submit_time','<',$i)
        ->whereRaw('? + run_time < deadline_time', array($i-3600))
        ->where('owner_id',$this->userId)
        ->where('status',0)
        ->groupBy('bundle_id')->get();
    foreach($bidsInPeriod as $bundle){
        $tmpBundle=new bundle($bundle['bundle_id'],$bundle['bid']);
        $bidRecords=bidsM::where('bundle_id','=',$i)->get();
        foreach($bidRecords as $bid){
            $tmpBundle->addBid($bid);
        }

0 个答案:

没有答案