diff options
author | Matthijs Kuiper <info@matthijskuiper.nl> | 2017-02-12 20:30:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-12 20:30:01 +0100 |
commit | 66b162b5f01c996fd8a5cd4e570e31f8483cdffa (patch) | |
tree | df404d4d8e26db5e564aece272c64896c38ce0f6 /html/pages/graph_mbreakdown.php | |
parent | 07b6b55355dc0555cf578067ff38e9e52c03fe7e (diff) | |
parent | 7abeb203d8b6d537a55b0dd9a1ccac32e6f948ec (diff) |
Merge pull request #3 from sn3p/sn3p/fix-mysql-group-by-errors4.2.9
Fix MySQL ONLY_FULL_GROUP_BY errors
Diffstat (limited to 'html/pages/graph_mbreakdown.php')
-rwxr-xr-x | html/pages/graph_mbreakdown.php | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/html/pages/graph_mbreakdown.php b/html/pages/graph_mbreakdown.php index 44ef717..1f386fe 100755 --- a/html/pages/graph_mbreakdown.php +++ b/html/pages/graph_mbreakdown.php @@ -3,28 +3,32 @@ $max_height = 100;; // Hourly Breakdown
$sql_ghours = "SELECT HOUR(time) AS res_hour, COUNT(*) AS res_count
-FROM uts_match WHERE $bgwhere GROUP by res_hour";
+ FROM uts_match
+ WHERE $bgwhere
+ GROUP by res_hour";
$q_ghours = mysql_query($sql_ghours) or die(mysql_error());
$hour_max = 0;
$hour_sum = 0;
while ($r_ghours = mysql_fetch_array($q_ghours)) {
- $gb_hour[$r_ghours['res_hour']] = $r_ghours['res_count'];
- if ($r_ghours['res_count'] > $hour_max) $hour_max = $r_ghours['res_count'];
- $hour_sum += $r_ghours['res_count'];
+ $gb_hour[$r_ghours['res_hour']] = $r_ghours['res_count'];
+ if ($r_ghours['res_count'] > $hour_max) $hour_max = $r_ghours['res_count'];
+ $hour_sum += $r_ghours['res_count'];
}
if ($hour_max == 0) return;
// Daily Breakdown
// We use WEEKDAY rather then DAYOFWEEK because now the week starts with Monday instead of Sunday
$sql_gdays = "SELECT WEEKDAY(time) AS res_day, COUNT(*) AS res_count
-FROM uts_match WHERE $bgwhere GROUP by res_day";
+ FROM uts_match
+ WHERE $bgwhere
+ GROUP by res_day";
$q_gdays = mysql_query($sql_gdays) or die(mysql_error());
$day_max = 0;
$day_sum = 0;
while ($r_gdays = mysql_fetch_array($q_gdays)) {
- $gb_day[$r_gdays['res_day']] = $r_gdays['res_count'];
- if ($r_gdays['res_count'] > $day_max) $day_max = $r_gdays['res_count'];
- $day_sum += $r_gdays['res_count'];
+ $gb_day[$r_gdays['res_day']] = $r_gdays['res_count'];
+ if ($r_gdays['res_count'] > $day_max) $day_max = $r_gdays['res_count'];
+ $day_sum += $r_gdays['res_count'];
}
// Monthly Breakdown
@@ -34,9 +38,9 @@ $q_gmonths = mysql_query($sql_gmonths) or die(mysql_error()); $month_max = 0;
$month_sum = 0;
while ($r_gmonths = mysql_fetch_array($q_gmonths)) {
- $gb_month[$r_gmonths['res_month']] = $r_gmonths['res_count'];
- if ($r_gmonths['res_count'] > $month_max) $month_max = $r_gmonths['res_count'];
- $month_sum += $r_gmonths['res_count'];
+ $gb_month[$r_gmonths['res_month']] = $r_gmonths['res_count'];
+ if ($r_gmonths['res_count'] > $month_max) $month_max = $r_gmonths['res_count'];
+ $month_sum += $r_gmonths['res_count'];
}
// very dirty hack, to deal with the $bgwhere containing an OR
@@ -54,19 +58,23 @@ if (substr_count($bgwhere, ' or ') == 0){ }
// Country Breakdown
-$sql_gcountries = "SELECT country AS res_country, COUNT(*) AS res_count FROM
- (SELECT p.country AS country FROM uts_player AS p, uts_match AS m
- WHERE m.id = p.matchid AND $bgwhere GROUP BY p.pid) AS res_table
-GROUP BY res_country ORDER BY res_count DESC";
+$sql_gcountries = "SELECT country AS res_country, COUNT(*) AS res_count
+FROM (SELECT p.country AS country
+ FROM uts_player AS p, uts_match AS m
+ WHERE m.id = p.matchid AND $bgwhere
+ GROUP BY p.pid, p.country) AS res_table
+GROUP BY res_country
+ORDER BY res_count DESC";
+
$q_gcountries = mysql_query($sql_gcountries) or die(mysql_error());
$country_max = 0;
$country_sum = 0;
$i = 0;
while ($r_gcountries = mysql_fetch_array($q_gcountries)) {
- $gb_country[$i] = $r_gcountries['res_country'] . ";" . $r_gcountries['res_count'];
- if ($r_gcountries['res_count'] > $country_max) $country_max = $r_gcountries['res_count'];
- $country_sum += $r_gcountries['res_count'];
- $i++;
+ $gb_country[$i] = $r_gcountries['res_country'] . ";" . $r_gcountries['res_count'];
+ if ($r_gcountries['res_count'] > $country_max) $country_max = $r_gcountries['res_count'];
+ $country_sum += $r_gcountries['res_count'];
+ $i++;
}
echo'
@@ -226,4 +234,4 @@ echo'<td class="grey" align="center" width="15"></td> </tbody>
</table>
<br>';
-?>
\ No newline at end of file +?>
|