Пример #1
0
$q = "select count(*) as d1 from nhl_players where date_expiration = '2099-12-31' and id_nhl != 0 and pos != 'TM'";
$data = DB::dbSelect($q);
$data = $data[0];
$nbre2update = $data['d1'];
$compteur = 1;
$q = "select id,first_name,last_name,id_nhl from nhl_players where date_expiration = '2099-12-31' and id_nhl != 0 and pos != 'TM' order by last_name,first_name";
$data = DB::dbSelect($q);
foreach ($data as $item) {
    $new_link = "";
    $id_player = $item['id'];
    $first_name = $item['first_name'];
    $last_name = $item['last_name'];
    $id_nhl = $item['id_nhl'];
    writelog("", "INTERPOOL", "{$compteur} de {$nbre2update}: {$last_name}, {$first_name} ({$id_nhl})...");
    $ch = curl_init();
    //curl_setopt($ch, CURLOPT_URL, "https://www.nhl.com/player/8471675");
    curl_setopt($ch, CURLOPT_URL, "https://www.nhl.com/player/{$id_nhl}");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $output = curl_exec($ch);
    curl_close($ch);
    //echo $output;
    $ar = explode(" ", $output);
    $new_link = $ar[count($ar) - 1];
    $q = "update interactivePool.nhl_players set id_nhl=\"{$new_link}\" where id = {$id_player} and date_expiration = '2099-12-31';";
    insert_query_in_file("/data/disk1/www/interPool/tmp/new_link_idnhl.sql", $q);
    $compteur++;
}
DB::dbClose();
?>

        $q = "update nhl_players set prospect='Y' where id = {$id_player} and date_expiration = '2099-12-31';";
        insert_query_in_file($INSERTFILE, $q);
    }
}
writelog($logFile, "info", "Update des joueurs HAS_BEEN");
// premièrement, on met tous les flags has_been à 'N'
writelog($logFile, "info", "Remise du champ has_been à 'N' pour tous les joueurs");
$q = "update nhl_players set has_been='N' where date_expiration = '2099-12-31' and has_been = 'Y';";
insert_query_in_file($INSERTFILE, $q);
$q = "select t1.id,t1.first_name,t1.last_name,t1.pos,t2.abbr\n     from nhl_players t1, teams t2\n     where t1.date_expiration = '2099-12-31'\n          and t1.birthday < '{$birthday_prospect_joueur}'\n          and t1.pos != 'TM'\n          and t1.team < 31\n          and t1.team = t2.id";
$data = DB::dbSelect($q);
foreach ($data as $item) {
    $id_player = $item['id'];
    $first_name = $item['first_name'];
    $last_name = $item['last_name'];
    $pos = $item['pos'];
    $abbr = $item['abbr'];
    if ($pos != "G") {
        $q = "select * from VMAT_joueurs_hist\n               where id_player = {$id_player}\n                    and (saison_id = {$last_year_id} or saison_id = {$two_years_ago_id})";
    } else {
        $q = "select * from VMAT_gardiens_hist\n               where id_player = {$id_player}\n                    and (saison_id = {$last_year_id} or saison_id = {$two_years_ago_id})";
    }
    $data = DB::dbSelect($q);
    if (count($data) == 0) {
        writelog($logFile, "info", "{$first_name} {$last_name} ({$abbr}) est un has_been...");
        $q = "update nhl_players set has_been='Y' where id = {$id_player} and date_expiration = '2099-12-31';";
        insert_query_in_file($INSERTFILE, $q);
    }
}
DB::dbClose();
echo "Pour inserer les informations dans les tables, veuillez loader le script {$INSERTFILE}\n";
Пример #3
0
function update_corr_values($if, $id_player, $playerName, $birthdate = "")
{
    $playerName = strtoupper($playerName);
    $wayA = array(0 => "way_1", 1 => "way_2", 2 => "way_3", 3 => "way_4", 4 => "way_5", 5 => "way_6", 6 => "way_7", 7 => "way_8", 8 => "way_9", 9 => "way_10");
    $birthdayA = array(0 => "birthday_1", 1 => "birthday_2", 2 => "birthday_3", 3 => "birthday_4", 4 => "birthday_5");
    $q = "select\n               way_1, way_2, way_3, way_4, way_5, way_6, way_7, way_8, way_9, way_10,\n               birthday_1, birthday_2, birthday_3, birthday_4, birthday_5\n           from\n               nhl_players_corr\n           where\n               id = {$id_player}";
    $data = DB::dbSelect($q);
    if (count($data) != 1) {
        writelog($logFile, "warning", "\tHHHMMMM, il y a plus d'une entrée avec l'id {$id_player} dans la table nhl_players_corr ({$playerName}). Pas normal...");
        return "";
    }
    $data = $data[0];
    foreach ($wayA as $item_way) {
        $value = $data[$item_way];
        if ($value == "") {
            break;
        }
    }
    foreach ($birthdayA as $item_birthday) {
        $value = $data[$item_birthday];
        if ($value == "") {
            break;
        }
    }
    if ($birthdate == "") {
        $q = "update nhl_players_corr set {$item_way}=\"{$playerName}\" where id = {$id_player};";
    } else {
        $q = "update nhl_players_corr set {$item_way}=\"{$playerName}\",{$item_birthday}='{$birthdate}' where id = {$id_player};";
    }
    insert_query_in_file($if, $q);
}