示例#1
0
 $objFileLog->startProcessing($uploadId, $totalCount, 'IP');
 logme("Start Processing on " . date('Y-M-D H:i:s'));
 foreach ($fileObject as $row) {
     $playerName = $row['player'];
     if (empty($playerName)) {
         die("Player Name is empty.script stopped");
     }
     $teamName = $row['team'];
     $teamId = array_search(strtolower($teamName), $teams);
     $playerId = array_search(strtolower($playerName), $players);
     /**
      * Team Not Found..
      * need to insert get the id back
      */
     if ($teamId === false) {
         $teamId = $objTeam->createTeam($teamName);
         $teams[$teamId] = strtolower($teamName);
     }
     if ($playerId === false) {
         $playerId = $objPlayer->createPlayer($playerName);
         $players[$playerId] = strtolower($playerName);
     }
     $assoc = [];
     $assoc['team'] = $teamId;
     $assoc['player'] = $playerId;
     $assoc['player_type'] = 'SC';
     $assoc['player_position'] = trim($row['position']);
     $assoc['player_score_year'] = trim($row['year']);
     $assoc['player_round'] = trim($row['round']);
     $assoc['player_price'] = trim($row['price']);
     $assoc['player_score_val'] = trim($row['score']);
 try {
     logme(trim($row['date']) . " " . trim($row['time']));
     $matchDate = new \DateTime(str_replace("/", "-", trim($row['date'])) . " " . trim(str_replace(" ", '', $row['time'])));
     $assoc['match_date'] = $matchDate->format('Y-m-d H:i:s');
 } catch (\Exception $e) {
     die($e->getMessage());
     $assoc['match_date'] = null;
 }
 $team1 = trim($row['team1']);
 $team1Id = array_search(strtolower($team1), $teams);
 /**
  * Team Not Found..
  * need to insert get the id back
  */
 if ($team1Id === false) {
     $team1Id = $objTeam->createTeam($team1);
     $teams[$team1Id] = strtolower($team1);
 }
 $assoc['team1'] = $team1Id;
 $team2 = trim($row['team2']);
 $team2Id = array_search(strtolower($team2), $teams);
 /**
  * Team Not Found..
  * need to insert get the id back
  */
 if ($team2Id === false) {
     $team2Id = $objTeam->createTeam($team2);
     $teams[$team2Id] = strtolower($team2);
 }
 $assoc['team2'] = $team2Id;
 $assoc['location'] = trim($row['location']);