Browse Source

Stats for index page

Axel Nordh 4 năm trước cách đây
mục cha
commit
f9e19580be

+ 4 - 0
OddsJavaFx/src/web/index.php

@@ -41,7 +41,11 @@ $leagues = $conn->getLeagues();
 </br>
 </br>
 
+<h2>Betting Stats</h2>
+  <?php 
+  $betSummary = $conn->getBettingSummary();
   
+  ?>
 
 </body>
 

+ 1 - 1
OddsJavaFx/src/web/matchTable.php

@@ -69,7 +69,7 @@ $betMarginAway = 1 + ($leagueInfo['betMarginAway'] / 100);
 
 <?php 
 
-$betStats = $conn->getBettingStats($leagueId)[0];
+$betStats = $conn->getBettingStats($leagueId);
 
 $wins = 0;
 $losses = 0;

+ 7 - 1
OddsJavaFx/src/web/webDbConnection.php

@@ -151,6 +151,12 @@ class WebDbConnection {
     public function getBettingStats($leagueId) {
         $sql = "SELECT * FROM Bets INNER JOIN SoccerResults sr ON matchId = sr.id WHERE leagueId = $leagueId AND Season = (SELECT MAX(season) FROM SoccerResults WHERE leagueId = $leagueId)";
         
-        return $this->getSqlAsArray($sql);
+        return $this->getSqlAsArray($sql)[0];
+    }
+    
+    public function getBettingSummary() {
+        $sql = "SELECT * FROM Bets INNER JOIN SoccerResults sr ON matchId = sr.id INNER JOIN League l ON leagueId = l.id INNER JOIN Country c ON l.countryId = c.id WHERE DATE(gameDate) > DATE_SUB(CURDATE(), INTERVAL 1 YEAR)";
+        
+        return $this->getSqlAsArray($sql)[0];
     }
 }