我制作了一个脚本,从我的数据库中获取数据,然后使用我数据库中每个玩家的数据来计算技能等级以及添加到数组中的其他参数。然后从该数组中将所有数据输入到我的数据库中的顶级列表中。
现在我的问题是它在localhost上运行时有0个错误但是当我在我的服务器上运行时它似乎只运行到:
echo $calculatediamondgrade." + ".$calculatediamondgradeforamted." + ".$summonerData->name."<br>";
我正在努力让它发挥作用,我在编码时没有看到任何问题,如果有的话,有人可以看看并让我思考你的想法。
<?php
set_time_limit(0);
require_once 'connect_db.php';
$emptyQuery = "TRUNCATE top_list;";
if ($conn->query($emptyQuery)) {
$sql = "SELECT summoner_info, tier_info, ranked_champs_info FROM players_data";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
$players = array();
$champsPoints = array();
while ($row = $result->fetch_assoc()) {
$summonerData = unserialize($row['summoner_info']);
$tierData = unserialize($row['tier_info']);
if ($tierData == NULL || !isset($tierData)) {
$tierData = new stdClass();
$tierData->tier = 'UNRANKED';
$tierEntry = new stdClass();
$tierEntry->division = '';
} else {
$tierData = $tierData[0];
$tierEntry = $tierData->entries[0];
}
$ranked_champs_infoData = unserialize($row['ranked_champs_info']);
if ($row['summoner_info'] !== "N;") {
if ($row['ranked_champs_info'] !== "N;") {
foreach ($ranked_champs_infoData->champions as $champData) {
$champIDs = $champData->id;
if (!$champIDs == 0) {
$totalsessionsplayedwithachampion = $champData->stats->totalSessionsPlayed;
if ($totalsessionsplayedwithachampion >= 10) {
$champstotalSessionsWon = $champData->stats->totalSessionsWon;
$champstotalSessionsLost = $champData->stats->totalSessionsLost;
$getMiniomskillsNamelistside = $champData->stats->totalMinionKills;
$KDAMinniomsSide = $getMiniomskillsNamelistside / ($totalsessionsplayedwithachampion);
if (isset($champData->stats) && isset($champData->stats->totalChampionKills)) {
/* Champion total kills */
$champsdatazkillz = $champData->stats->totalChampionKills;
} else {
$champsdatazkillz = 0;
}
if (isset($champData->stats) && isset($champData->stats->totalAssists)) {
/* Champion total assists */
$champsdatazassitsz = $champData->stats->totalAssists;
} else {
$champsdatazassitsz = 0;
}
if (isset($champData->stats) && isset($champData->stats->totalDeathsPerSession)) {
/* Champion total deaths */
$champsdatazdeathz = $champData->stats->totalDeathsPerSession;
} else {
$champsdatazdeathz = 0;
}
if ($champsdatazdeathz == 0) {
$KDAsidechamps = ($champsdatazkillz + $champsdatazassitsz);
} else {
$KDAsidechamps = ($champsdatazkillz + $champsdatazassitsz) / $champsdatazdeathz;
}
if ($tierData->tier == "CHALLENGER") {
$championrankMOD = '1.9';
$championrankKDA = 0.95;
$championrankKDAminniom = 0.0095;
} else if ($tierData->tier == "MASTER") {
$championrankMOD = '1.85';
$championrankKDA = 0.93;
$championrankKDAminniom = 0.0093;
} else if ($tierData->tier == "DIAMOND") {
$championrankMOD = '1.8';
$championrankKDA = 0.9;
$championrankKDAminniom = 0.0090;
} else if ($tierData->tier == "PLATINUM") {
$championrankMOD = '1.7';
$championrankKDA = 0.86;
$championrankKDAminniom = 0.0087;
} else if ($tierData->tier == "GOLD") {
$championrankMOD = '1.65';
$championrankKDA = 0.82;
$championrankKDAminniom = 0.0085;
} else if ($tierData->tier == "SILVER") {
$championrankMOD = '1.55';
$championrankKDA = 0.75;
$championrankKDAminniom = 0.0083;
} else if ($tierData->tier == "BRONZE") {
$championrankMOD = '1.45';
$championrankKDA = 0.71;
$championrankKDAminniom = 0.0080;
} else if ($tierData->tier == "UNRANKED") {
$championrankMOD = '1.55';
$championrankKDA = 0.75;
$championrankKDAminniom = 0.0083;
}
$calculatediamondgrade = ((pow(number_format((float)$KDAsidechamps, 2, '.', ''), 1 / 2) * $championrankKDA) + (pow(number_format((float)$KDAMinniomsSide, 2, '.', ''), 1 / 20) * $championrankKDAminniom)) * pow((($champstotalSessionsWon + 0.5) / (($champstotalSessionsWon + 0.4) + ($champstotalSessionsLost + 0.3))), 1 / 1.1) * pow((($champstotalSessionsWon) + ($champstotalSessionsLost - 0.4)), 1 / 8) * $championrankMOD;
$calculatediamondgradeforamted = number_format((float)$calculatediamondgrade, 3, '.', '') * (1000);
echo $calculatediamondgrade . " + " . $calculatediamondgradeforamted . " + " . $summonerData->name . "<br>";
array_push($players, array(
'champId' => $champData->id,
'profileiconid' => $summonerData->profileIconId,
'playerName' => $summonerData->name,
'tier' => $tierData->tier,
'division' => $tierEntry->division,
'championPoints' => $calculatediamondgradeforamted,
'gamesplayed' => $totalsessionsplayedwithachampion
));
array_push($champsPoints, $calculatediamondgradeforamted);
}
}
}
}
}
}
rsort($champsPoints);
usort($players, function ($a, $b) use ($champsPoints) {
$pos_a = array_search($a['championPoints'], $champsPoints);
$pos_b = array_search($b['championPoints'], $champsPoints);
return $pos_a - $pos_b;
});
$championsPoints = array_values(array_unique($champsPoints));
$playersByCP = array();
foreach ($championsPoints as $champsPoint) {
$sameCPs = array();
foreach ($players as $player) {
$sameCP = array();
if ($player['championPoints'] == $champsPoint) {
switch ($player['tier']) {
case 'BRONZE':
switch ($player['division']) {
case 'I':
$sameCP['tier'] = 'z5';
break;
case 'II':
$sameCP['tier'] = 'z4';
break;
case 'III':
$sameCP['tier'] = 'z3';
break;
case 'IV':
$sameCP['tier'] = 'z2';
break;
case 'V':
$sameCP['tier'] = 'z1';
break;
default:
$sameCP['tier'] = 'Error Bronze';
break;
}
break;
case 'SILVER':
switch ($player['division']) {
case 'I':
$sameCP['tier'] = 'y5';
break;
case 'II':
$sameCP['tier'] = 'y4';
break;
case 'III':
$sameCP['tier'] = 'y3';
break;
case 'IV':
$sameCP['tier'] = 'y2';
break;
case 'V':
$sameCP['tier'] = 'y1';
break;
default:
$sameCP['tier'] = 'Error Silver';
break;
}
break;
case 'GOLD':
switch ($player['division']) {
case 'I':
$sameCP['tier'] = 'x5';
break;
case 'II':
$sameCP['tier'] = 'x4';
break;
case 'III':
$sameCP['tier'] = 'x3';
break;
case 'IV':
$sameCP['tier'] = 'x2';
break;
case 'V':
$sameCP['tier'] = 'x1';
break;
default:
$sameCP['tier'] = 'Error Gold';
break;
}
break;
case 'PLATINUM':
switch ($player['division']) {
case 'I':
$sameCP['tier'] = 'w5';
break;
case 'II':
$sameCP['tier'] = 'w4';
break;
case 'III':
$sameCP['tier'] = 'w3';
break;
case 'IV':
$sameCP['tier'] = 'w2';
break;
case 'V':
$sameCP['tier'] = 'w1';
break;
default:
$sameCP['tier'] = 'Error Platinum';
break;
}
break;
case 'DIAMOND':
switch ($player['division']) {
case 'I':
$sameCP['tier'] = 'v5';
break;
case 'II':
$sameCP['tier'] = 'v4';
break;
case 'III':
$sameCP['tier'] = 'v3';
break;
case 'IV':
$sameCP['tier'] = 'v2';
break;
case 'V':
$sameCP['tier'] = 'v1';
break;
default:
$sameCP['tier'] = 'Error Diamond';
break;
}
break;
case 'MASTER':
$sameCP['tier'] = 'u';
break;
case 'CHALLENGER':
$sameCP['tier'] = 'u';
break;
default:
$sameCP['tier'] = 'Error Tier';
break;
}
$sameCP['player'] = $player;
array_push($sameCPs, $sameCP);
}
}
sort($sameCPs);
foreach ($sameCPs as $sameCP) {
array_push($playersByCP, $sameCP['player']);
}
}
foreach ($playersByCP as $position => $playerByCP) {
$tableRow = serialize($playerByCP);
if ($playerByCP['gamesplayed'] >= 10) {
$sql2 = 'INSERT INTO top_list (position, table_row, sum_name, champ_id) VALUES (' . $position . ', \'' . $tableRow . '\', \'' . mb_strtolower(str_replace(' ', '', $playerByCP['playerName']), 'UTF-8') . '\', \'' . mb_strtolower(str_replace(' ', '', $playerByCP['champId']), 'UTF-8') . '\')';
if ($conn->query($sql2)) {
echo 'Insert: ' . mb_strtolower(str_replace(' ', '', $playerByCP['playerName']), 'UTF-8') . '<br>';
} else {
echo 'Failed: ' . $conn->error . '<br>';
}
}
}
}
}
?>
答案 0 :(得分:0)
编辑php.ini时,请确保它是您正在编辑的正确文件。 看看这里:How to know which php.ini is used?
尝试在服务器配置文件中明确设置执行时间:
max_execution_time = 360
特定服务器配置可能正在处理与本地主机不同的默认值。