Php 我怎样才能腾出忙桌?

Php 我怎样才能腾出忙桌?,php,mysql,xml,transactions,Php,Mysql,Xml,Transactions,我在数据库中有历史表,每10分钟使用cron从xml提要中填充一次新数据 Xml提要相当长,而且我的表持续地忙碌,我也从视图侧使用该表。 所以我的视图端的进程正在等待,直到cron的进程完成 你认为我怎样才能释放进程?使用多个连接,或者将数据复制到另一个表,cron不使用什么 逻辑是这样的: FUNCTION HISTORIC TO DB BEGIN TRY CONNECT BEGIN TRANSACTION BEGIN LOOP EXECUTE END LOOP COMMIT TRANSACT

我在数据库中有历史表,每10分钟使用cronxml提要中填充一次新数据

Xml提要相当长,而且我的表持续地忙碌,我也从视图侧使用该表。 所以我的视图端的进程正在等待,直到cron的进程完成

你认为我怎样才能释放进程?使用多个连接,或者将数据复制到另一个表,cron不使用什么

逻辑是这样的:

FUNCTION HISTORIC TO DB
BEGIN TRY
CONNECT
BEGIN TRANSACTION
BEGIN LOOP
EXECUTE
END LOOP
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
CLOSE
END CATCH
function resultsToHistoric(){
try{
    $con = new Connect();
    $countries = $this->ResultCountries;
    foreach($countries as $country){
        $this->PDO->beginTransaction();
        $path = "feeds/results/{$country}res.xml";
        $results = $this->parser->parseFile($path);
        $drzava = $this->filterCountries($results->attributes()->country).":";
        foreach($results->league as $league){
        $leagueid = $league->attributes()->id;
            $liga = $league->attributes()->name;
            $lg2 = '';
            if(!contains(strtolower($liga),strtolower($drzava))){
                $lg2 = ucfirst($drzava) . ' ' . ucfirst($liga);  
            }
            else{
                $lg2 = $liga;
            }
            //var_dump($league->stage->aggregate);
            $leaguename = $this->getMap2($lg2);
            $season = $league->attributes()->season;
            $lgstage = NULL;
            if($league->week){
              $weekroot = $league->week;
            }
            elseif($league->week){
              $weekroot = $league->week;
            }
            elseif($league->aggregate){
                $weekroot = $league->aggregate;
            }
            else{
                //$weekroot = $league->stage;
                foreach($league->stage as $stage){
                    if($stage->week){
                        $weekroot = $stage->week;
                    }
                    elseif($stage->aggregate){
                        $weekroot = $stage->aggregate;
                    }
                    else{
                        $weekroot = $league;
                    }
                }
            }
            foreach($weekroot as $week){
            $round  = 0;
            if($week->attributes()->number!=NULL){
                $round = $week->attributes()->number;
            }
            //print_r($week);
            foreach($week->match as $match){
                //var_dump($match);
                $fixid = 0;
                if($match->attributes()->id == 0 || $match->attributes()->id == ''){
                    if($match->attributes()->alternate_id == 0 || $match->attributes()->id == ''){
                        $fixid = $match->attributes()->alternate_id_2;
                    }
                    else{
                        $fixid = $match->attributes()->alternate_id;
                    }
                }
                else{
                    $fixid = $match->attributes()->id;
                }
                $dbdate = date('Y-m-d',strtotime($match->attributes()->date));
                $dbtime = date('H:i:s', strtotime($match->attributes()->time));

                $datetime = date('Y-m-d H:i:s',strtotime($dbdate . $dbtime));
                $fcountry = $this->filterCountries($results->attributes()->country);    

                //echo $fcountry;
                //$home = $match->home->attributes()->name;
                //$away = $match->away->attributes()->name;
                $home = '';
                $away = '';
                $homeid = 0;
                $awayid = 0;
                $hgoals = 0;
                $agoals = 0;
                if($match->home){
                $home = $this->getMap($fcountry,$match->home->attributes()->name);
                $away = $this->getMap($fcountry,$match->away->attributes()->name);
                $homeid = $this->filterTeams($fcountry,$match->home->attributes()->id);
                $awayid = $this->filterTeams($fcountry,$match->away->attributes()->id); 

                $hgoals = $match->home->attributes()->score;
                $agoals = $match->away->attributes()->score;
                }

                $eventname = $home . ' - ' . $away;

                $halftimehomegoals = 0;
                $halftimeawaygoals = 0;
                if($match->halftime->attributes()->score != NULL){
                    $halftime = explode("-",$match->halftime->attributes()->score);
                    $halftimehomegoals = (int)$halftime[0];
                    if(array_key_exists(1,$halftime)){
                        $halftimeawaygoals = (int)$halftime[1];
                    }
                }

                $homescore = '';
                $awayscore = '';
                if($match->goals->goal != NULL){
                  foreach($match->goals->goal as $goal){
                      if($goal->attributes()->team == 'home'){
                         $homescore .= $goal->attributes()->minute.': '.
                         $goal->attributes()->player.'; ';
                      }
                      elseif($goal->attributes()->team == 'away'){
                         $awayscore .= $goal->attributes()->player.'; ';
                      }
                  }
                }
                $homesquad = '';
                $awaysquad = '';
                if($match->lineups != NULL){
                  foreach($match->lineups as $lineup){
                      if($lineup->home->player != NULL){
                        foreach($lineup->home->player as $player){
                            $homesquad .= $player->attributes()->name . '; ';
                        }
                      }
                      if($lineup->away->player != NULL){
                        foreach($lineup->away->player as $player){
                            $awaysquad .= $player->attributes()->name . '; ';
                        }
                      }
                  }
                }

                $homesub = '';
                $awaysub = '';
                if($match->substitutions != NULL){
                    foreach($match->substitutions as $subs){
                        if($subs->home->substitution != NULL){
                            foreach($subs->home->substitution as $sub){
                                $homesub .= $sub->attributes()->minute."' in: ".
                                $sub->attributes()->player_in_name . '; ' . ' out: ' .
                                $sub->attributes()->player_out_name . '; ';
                            }
                        }
                        if($subs->away->substitution != NULL){
                            foreach($subs->away->substitution as $sub){
                                $awaysub .= $sub->attributes()->minute."' in: ".
                                $sub->attributes()->player_in_name . '; ' .
                                $sub->attributes()->player_out_name . '; ';
                            }
                        }
                    }
                }

                //if($homesquad!='' || $awaysquad != ''){
              $this->execHistoric($fixid,$fixid,$datetime,$round,NULL,$leaguename,$leagueid,strtolower($fcountry),$eventname, $homeid, $home, NULL, $hgoals, $halftimehomegoals,NULL,NULL,NULL,$homescore,NULL, $homesquad,NULL, NULL, NULL, NULL, NULL, NULL, NULL, $away, $awayid, NULL, $agoals, $halftimeawaygoals, NULL, NULL, NULL, $awayscore,NULL,$awaysquad,NULL,NULL,NULL, NULL, NULL, NULL, NULL, $homesub, $awaysub,NULL, NULL, NULL, NULL , 'tipgin',$season);
                //continue; 
                //}
                echo $leaguename . ' ' . $leagueid . ' ' . $fixid . ' ' . $eventname.'<br>';
                echo 'home squad: ' .$homesquad.'<br>';
                echo 'away squad: ' .$awaysquad.'<br>';
                echo 'home sub: ' .$homesub.'<br>';
                echo 'away sub: ' .$awaysub.'<br>';
                echo 'home scorers: ' .$homescore.'<br>';
                echo 'away scorers: ' .$awayscore.'<br>';
            }
             // }else continue;
            }
        }
        //error_log(" RESULT ENDED: ".$country. date('Y-m-d H:i:s'),3,'php/errorlog.txt');
        $this->PDO->commit(); //SAVE
        error_log(" ENDED HISTORIC: ".$country. date('Y-m-d H:i:s'),3,'php/errorlog.txt');
        }
        $con->close(); //CLOSE
}
catch(Exception $e){
    echo $e;
}
}

function execHistoric($hisid,$fixid,$date,$round,$spec,$league,$leagueid, $country, $eventname, $hteamid,$hteam,$hcorn,$hgoals,$hthgoals,$hshots,$hsont,$hfouls,$hgd,$hgk,$hdf,$hmdf,$hfw,$hls,$hlc,$hycard,$hrcard,$htf,$ateam,$ateamid,$acorn,$agoals,$athgoals,$ashots,$asont,$afouls,$agd,$agk,$adf,$amdf,$afw,$als,$alc,$aycard,$arcard,$atf,$hsubd,$asubd,$htycd,$atycd,$htrcd,$atrcd,$source,$season){
    $stmt = $this->PDO->prepare($this->insHis);
    $stmt->bindParam(':hisID', $hisid);
    $stmt->bindParam(':fixID',$fixid);
    $stmt->bindParam(':pdate',$date);
    $stmt->bindParam(':round',$round);
    $stmt->bindParam(':spectators',$spec);
    $stmt->bindParam(':league',$league);
    $stmt->bindParam(':leagueid',$leagueid);
    $stmt->bindParam(':country',$country);
    $stmt->bindParam(':eventname',$eventname);
    $stmt->bindParam(':homeTeam',$hteam);
    $stmt->bindParam(':homeTeamID',$hteamid);
    $stmt->bindParam(':homeCorners',$hcorn);
    $stmt->bindParam(':homeGoals',$hgoals);
    $stmt->bindParam(':halfTimeHomeGoals', $hthgoals);
    $stmt->bindParam(':homeShots', $hshots);
    $stmt->bindParam(':homeShotsOnTarget', $hsont);
    $stmt->bindParam(':homeFouls',$hfouls);
    $stmt->bindParam(':homeGoalDetails', $hgd);
    $stmt->bindParam(':homeLineupGoalkeeper',$hgk);
    $stmt->bindParam(':homeLineupDefense',$hdf);
    $stmt->bindParam(':homeLineupMidfield',$hmdf);
    $stmt->bindParam(':homeLineupForward',$hfw);
    $stmt->bindParam(':homeLineupSubstitutes',$hls);
    $stmt->bindParam(':homeLineupCoach',$hlc);
    $stmt->bindParam(':homeYellowCards',$hycard);
    $stmt->bindParam(':homeRedCards',$hrcard);
    $stmt->bindParam(':homeTeamFormation',$htf);
    $stmt->bindParam(':awayTeam',$ateam);
    $stmt->bindParam(':awayTeamID',$ateamid);
    $stmt->bindParam(':awayCorners', $acorn);
    $stmt->bindParam(':awayGoals', $agoals);
    $stmt->bindParam(':halfTimeAwayGoals', $athgoals);
    $stmt->bindParam(':awayShots',$ashots);
    $stmt->bindParam(':awayShotsOnTarget', $asont);
    $stmt->bindParam(':awayFouls',$afouls);
    $stmt->bindParam(':awayGoalDetails',$agd);
    $stmt->bindParam(':awayLineupGoalkeeper',$agk);
    $stmt->bindParam(':awayLineupDefense',$adf);
    $stmt->bindParam(':awayLineupMidfield',$amdf);
    $stmt->bindParam(':awayLineupForward',$afw);
    $stmt->bindParam(':awayLineupSubstitutes',$als);
    $stmt->bindParam(':awayLineupCoach',$alc);
    $stmt->bindParam(':awayYellowCards',$aycard);
    $stmt->bindParam(':awayRedCards',$arcard);
    $stmt->bindParam(':awayTeamFormation',$atf);
    $stmt->bindParam(':homeSubDetails', $hsubd);
    $stmt->bindParam(':awaySubDetails', $asubd);
    $stmt->bindParam(':homeTeamYellowCardDetails', $htycd);
    $stmt->bindParam(':awayTeamYellowCardDetails',$atycd);
    $stmt->bindParam(':homeTeamRedCardDetails', $htrcd);
    $stmt->bindParam(':awayTeamRedCardDetails', $atrcd);
    $stmt->bindParam(':source',$source);
    $stmt->bindParam(':season',$season);
    $stmt->execute();
}
完整代码:

FUNCTION HISTORIC TO DB
BEGIN TRY
CONNECT
BEGIN TRANSACTION
BEGIN LOOP
EXECUTE
END LOOP
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
CLOSE
END CATCH
function resultsToHistoric(){
try{
    $con = new Connect();
    $countries = $this->ResultCountries;
    foreach($countries as $country){
        $this->PDO->beginTransaction();
        $path = "feeds/results/{$country}res.xml";
        $results = $this->parser->parseFile($path);
        $drzava = $this->filterCountries($results->attributes()->country).":";
        foreach($results->league as $league){
        $leagueid = $league->attributes()->id;
            $liga = $league->attributes()->name;
            $lg2 = '';
            if(!contains(strtolower($liga),strtolower($drzava))){
                $lg2 = ucfirst($drzava) . ' ' . ucfirst($liga);  
            }
            else{
                $lg2 = $liga;
            }
            //var_dump($league->stage->aggregate);
            $leaguename = $this->getMap2($lg2);
            $season = $league->attributes()->season;
            $lgstage = NULL;
            if($league->week){
              $weekroot = $league->week;
            }
            elseif($league->week){
              $weekroot = $league->week;
            }
            elseif($league->aggregate){
                $weekroot = $league->aggregate;
            }
            else{
                //$weekroot = $league->stage;
                foreach($league->stage as $stage){
                    if($stage->week){
                        $weekroot = $stage->week;
                    }
                    elseif($stage->aggregate){
                        $weekroot = $stage->aggregate;
                    }
                    else{
                        $weekroot = $league;
                    }
                }
            }
            foreach($weekroot as $week){
            $round  = 0;
            if($week->attributes()->number!=NULL){
                $round = $week->attributes()->number;
            }
            //print_r($week);
            foreach($week->match as $match){
                //var_dump($match);
                $fixid = 0;
                if($match->attributes()->id == 0 || $match->attributes()->id == ''){
                    if($match->attributes()->alternate_id == 0 || $match->attributes()->id == ''){
                        $fixid = $match->attributes()->alternate_id_2;
                    }
                    else{
                        $fixid = $match->attributes()->alternate_id;
                    }
                }
                else{
                    $fixid = $match->attributes()->id;
                }
                $dbdate = date('Y-m-d',strtotime($match->attributes()->date));
                $dbtime = date('H:i:s', strtotime($match->attributes()->time));

                $datetime = date('Y-m-d H:i:s',strtotime($dbdate . $dbtime));
                $fcountry = $this->filterCountries($results->attributes()->country);    

                //echo $fcountry;
                //$home = $match->home->attributes()->name;
                //$away = $match->away->attributes()->name;
                $home = '';
                $away = '';
                $homeid = 0;
                $awayid = 0;
                $hgoals = 0;
                $agoals = 0;
                if($match->home){
                $home = $this->getMap($fcountry,$match->home->attributes()->name);
                $away = $this->getMap($fcountry,$match->away->attributes()->name);
                $homeid = $this->filterTeams($fcountry,$match->home->attributes()->id);
                $awayid = $this->filterTeams($fcountry,$match->away->attributes()->id); 

                $hgoals = $match->home->attributes()->score;
                $agoals = $match->away->attributes()->score;
                }

                $eventname = $home . ' - ' . $away;

                $halftimehomegoals = 0;
                $halftimeawaygoals = 0;
                if($match->halftime->attributes()->score != NULL){
                    $halftime = explode("-",$match->halftime->attributes()->score);
                    $halftimehomegoals = (int)$halftime[0];
                    if(array_key_exists(1,$halftime)){
                        $halftimeawaygoals = (int)$halftime[1];
                    }
                }

                $homescore = '';
                $awayscore = '';
                if($match->goals->goal != NULL){
                  foreach($match->goals->goal as $goal){
                      if($goal->attributes()->team == 'home'){
                         $homescore .= $goal->attributes()->minute.': '.
                         $goal->attributes()->player.'; ';
                      }
                      elseif($goal->attributes()->team == 'away'){
                         $awayscore .= $goal->attributes()->player.'; ';
                      }
                  }
                }
                $homesquad = '';
                $awaysquad = '';
                if($match->lineups != NULL){
                  foreach($match->lineups as $lineup){
                      if($lineup->home->player != NULL){
                        foreach($lineup->home->player as $player){
                            $homesquad .= $player->attributes()->name . '; ';
                        }
                      }
                      if($lineup->away->player != NULL){
                        foreach($lineup->away->player as $player){
                            $awaysquad .= $player->attributes()->name . '; ';
                        }
                      }
                  }
                }

                $homesub = '';
                $awaysub = '';
                if($match->substitutions != NULL){
                    foreach($match->substitutions as $subs){
                        if($subs->home->substitution != NULL){
                            foreach($subs->home->substitution as $sub){
                                $homesub .= $sub->attributes()->minute."' in: ".
                                $sub->attributes()->player_in_name . '; ' . ' out: ' .
                                $sub->attributes()->player_out_name . '; ';
                            }
                        }
                        if($subs->away->substitution != NULL){
                            foreach($subs->away->substitution as $sub){
                                $awaysub .= $sub->attributes()->minute."' in: ".
                                $sub->attributes()->player_in_name . '; ' .
                                $sub->attributes()->player_out_name . '; ';
                            }
                        }
                    }
                }

                //if($homesquad!='' || $awaysquad != ''){
              $this->execHistoric($fixid,$fixid,$datetime,$round,NULL,$leaguename,$leagueid,strtolower($fcountry),$eventname, $homeid, $home, NULL, $hgoals, $halftimehomegoals,NULL,NULL,NULL,$homescore,NULL, $homesquad,NULL, NULL, NULL, NULL, NULL, NULL, NULL, $away, $awayid, NULL, $agoals, $halftimeawaygoals, NULL, NULL, NULL, $awayscore,NULL,$awaysquad,NULL,NULL,NULL, NULL, NULL, NULL, NULL, $homesub, $awaysub,NULL, NULL, NULL, NULL , 'tipgin',$season);
                //continue; 
                //}
                echo $leaguename . ' ' . $leagueid . ' ' . $fixid . ' ' . $eventname.'<br>';
                echo 'home squad: ' .$homesquad.'<br>';
                echo 'away squad: ' .$awaysquad.'<br>';
                echo 'home sub: ' .$homesub.'<br>';
                echo 'away sub: ' .$awaysub.'<br>';
                echo 'home scorers: ' .$homescore.'<br>';
                echo 'away scorers: ' .$awayscore.'<br>';
            }
             // }else continue;
            }
        }
        //error_log(" RESULT ENDED: ".$country. date('Y-m-d H:i:s'),3,'php/errorlog.txt');
        $this->PDO->commit(); //SAVE
        error_log(" ENDED HISTORIC: ".$country. date('Y-m-d H:i:s'),3,'php/errorlog.txt');
        }
        $con->close(); //CLOSE
}
catch(Exception $e){
    echo $e;
}
}

function execHistoric($hisid,$fixid,$date,$round,$spec,$league,$leagueid, $country, $eventname, $hteamid,$hteam,$hcorn,$hgoals,$hthgoals,$hshots,$hsont,$hfouls,$hgd,$hgk,$hdf,$hmdf,$hfw,$hls,$hlc,$hycard,$hrcard,$htf,$ateam,$ateamid,$acorn,$agoals,$athgoals,$ashots,$asont,$afouls,$agd,$agk,$adf,$amdf,$afw,$als,$alc,$aycard,$arcard,$atf,$hsubd,$asubd,$htycd,$atycd,$htrcd,$atrcd,$source,$season){
    $stmt = $this->PDO->prepare($this->insHis);
    $stmt->bindParam(':hisID', $hisid);
    $stmt->bindParam(':fixID',$fixid);
    $stmt->bindParam(':pdate',$date);
    $stmt->bindParam(':round',$round);
    $stmt->bindParam(':spectators',$spec);
    $stmt->bindParam(':league',$league);
    $stmt->bindParam(':leagueid',$leagueid);
    $stmt->bindParam(':country',$country);
    $stmt->bindParam(':eventname',$eventname);
    $stmt->bindParam(':homeTeam',$hteam);
    $stmt->bindParam(':homeTeamID',$hteamid);
    $stmt->bindParam(':homeCorners',$hcorn);
    $stmt->bindParam(':homeGoals',$hgoals);
    $stmt->bindParam(':halfTimeHomeGoals', $hthgoals);
    $stmt->bindParam(':homeShots', $hshots);
    $stmt->bindParam(':homeShotsOnTarget', $hsont);
    $stmt->bindParam(':homeFouls',$hfouls);
    $stmt->bindParam(':homeGoalDetails', $hgd);
    $stmt->bindParam(':homeLineupGoalkeeper',$hgk);
    $stmt->bindParam(':homeLineupDefense',$hdf);
    $stmt->bindParam(':homeLineupMidfield',$hmdf);
    $stmt->bindParam(':homeLineupForward',$hfw);
    $stmt->bindParam(':homeLineupSubstitutes',$hls);
    $stmt->bindParam(':homeLineupCoach',$hlc);
    $stmt->bindParam(':homeYellowCards',$hycard);
    $stmt->bindParam(':homeRedCards',$hrcard);
    $stmt->bindParam(':homeTeamFormation',$htf);
    $stmt->bindParam(':awayTeam',$ateam);
    $stmt->bindParam(':awayTeamID',$ateamid);
    $stmt->bindParam(':awayCorners', $acorn);
    $stmt->bindParam(':awayGoals', $agoals);
    $stmt->bindParam(':halfTimeAwayGoals', $athgoals);
    $stmt->bindParam(':awayShots',$ashots);
    $stmt->bindParam(':awayShotsOnTarget', $asont);
    $stmt->bindParam(':awayFouls',$afouls);
    $stmt->bindParam(':awayGoalDetails',$agd);
    $stmt->bindParam(':awayLineupGoalkeeper',$agk);
    $stmt->bindParam(':awayLineupDefense',$adf);
    $stmt->bindParam(':awayLineupMidfield',$amdf);
    $stmt->bindParam(':awayLineupForward',$afw);
    $stmt->bindParam(':awayLineupSubstitutes',$als);
    $stmt->bindParam(':awayLineupCoach',$alc);
    $stmt->bindParam(':awayYellowCards',$aycard);
    $stmt->bindParam(':awayRedCards',$arcard);
    $stmt->bindParam(':awayTeamFormation',$atf);
    $stmt->bindParam(':homeSubDetails', $hsubd);
    $stmt->bindParam(':awaySubDetails', $asubd);
    $stmt->bindParam(':homeTeamYellowCardDetails', $htycd);
    $stmt->bindParam(':awayTeamYellowCardDetails',$atycd);
    $stmt->bindParam(':homeTeamRedCardDetails', $htrcd);
    $stmt->bindParam(':awayTeamRedCardDetails', $atrcd);
    $stmt->bindParam(':source',$source);
    $stmt->bindParam(':season',$season);
    $stmt->execute();
}
函数resultsToHistoric(){
试一试{
$con=新连接();
$countries=$this->ResultCountries;
foreach($国家作为$国家){
$this->PDO->beginTransaction();
$path=“feeds/results/{$country}res.xml”;
$results=$this->parser->parseFile($path);
$drzava=$this->filterCountries($results->attributes()->country)。“:”;
foreach($results->league as$league){
$leagueid=$league->attributes()->id;
$liga=$league->attributes()->name;
$lg2='';
如果(!包含(strtolower($liga),strtolower($drzava))){
$lg2=ucfirst($drzava)。“”.ucfirst($liga);
}
否则{
$lg2=$liga;
}
//变量转储($league->stage->aggregate);
$leaguename=$this->getMap2($lg2);
$season=$league->attributes()->season;
$lgstage=NULL;
如果($league->week){
$weekroot=$league->week;
}
elseif($league->week){
$weekroot=$league->week;
}
elseif($league->aggregate){
$weekroot=$league->aggregate;
}
否则{
//$weekroot=$league->stage;
foreach($league->stage as$stage){
如果($stage->week){
$weekroot=$stage->week;
}
elseif($stage->aggregate){
$weekroot=$stage->aggregate;
}
否则{
$weekroot=$league;
}
}
}
foreach($weekroot作为$week){
$round=0;
如果($week->attributes()->number!=NULL){
$round=$week->attributes()->number;
}
//印刷(每星期);
foreach($week->match as$match){
//var_dump($match);
$fixid=0;
如果($match->attributes()->id==0 | |$match->attributes()->id==''){
如果($match->attributes()->alternate|u id==0 ||$match->attributes()->id==0){
$fixid=$match->attributes()->alternate_id_2;
}
否则{
$fixid=$match->attributes()->alternate\u id;
}
}
否则{
$fixid=$match->attributes()->id;
}
$dbdate=date('Y-m-d',strottime($match->attributes()->date));
$dbtime=date('H:i:s',strottime($match->attributes()->time));
$datetime=date('Y-m-dh:i:s',strottime($dbdate.$dbtime));
$fcountry=$this->filterCountries($results->attributes()->country);
//echo$fcountry;
//$home=$match->home->attributes()->name;
//$away=$match->away->attributes()->name;
$home='';
$away='';
$homeid=0;
$awayid=0;
$hgoals=0;
$AGOLS=0;
如果($match->home){
$home=$this->getMap($fccountry,$match->home->attributes()->name);
$away=$this->getMap($fccountry,$match->away->attributes()->name);
$homeid=$this->filterTeams($fccountry,$match->home->attributes()->id);
$awayid=$this->filterTeams($fccountry,$match->away->attributes()->id);
$hgoals=$match->home->attributes()->score;
$AGOLS=$match->away->attributes()->得分;
}
$eventname=$home.'-'.$away;
$halftimehomegoals=0;
$halftimeawaygoals=0;
如果($match->half-time->attributes()->score!=NULL){
$halftime=分解(“-”,$match->halftime->attributes()->score);
$halftimehomegoals=(int)$halftime[0];
如果(数组\键\存在(1,$halftime)){
$halftimeawaygoals=(int)$halftime[1];
}
}
$homescore='';
$awayscore='';
如果($match->goals->goal!=NULL){
foreach($match->goals->goals作为$goal的目标){
如果($goal->attributes()->team=='home'){
$homescore.=$goal->attributes()->minute.:'。
$goal->attributes()->player。“;”;
}
elseif($goal->attributes()->team=='away'){
$awayscore.=$goal->attributes()->player;
}
}
}
$homesquad='';
$awaysquad='';
如果($match->lineups!=NULL){
foreach($match->lineups as$lineup){
如果($lineup->home->player!=NULL){
foreach($lineup->home->player as$player){
$homesquad.=$player->attributes()->name;
}
}
如果($lineup->away->player!=NULL){
foreach($lineup->away->player as$player){
$awaysquad.=$playe