Pārlūkot izejas kodu

Home/away team get results fixed

Axel Nordh 4 gadi atpakaļ
vecāks
revīzija
08fb27c040
1 mainītis faili ar 12 papildinājumiem un 12 dzēšanām
  1. 12 12
      OddsJavaFx/src/web/webDbConnection.php

+ 12 - 12
OddsJavaFx/src/web/webDbConnection.php

@@ -81,10 +81,10 @@ class WebDbConnection {
             $league = $this->getLeagueInfo($leagueId);
 
             echo "</br></br> League </br>";
-            var_dump($league);
+            var_dump($league[0]);
             
-            $lookback = $league['lookback'];
-            $betMargin = $league['betMargin'];
+            $lookback = $league[0]['lookback'];
+            $betMargin = $league[0]['betMargin'];
             
             $homeTeamResults = $this->getTeamResults($match['homeTeam'], $lookback, true);
             $awayTeamResults = $this->getTeamResults($match['awayTeam'], $lookback, false);
@@ -126,19 +126,19 @@ class WebDbConnection {
     public function getTeamResults($teamId, $numResults, $isHomeTeam) {
         $sql = "";
         if ($isHomeTeam) {
-            $sql = "SELECT count(case when homeScore > awayScore then 1 end) wins, " +
-            "count(case when awayScore > homeScore then 1 end) lost, " +
-            "count(case when homeScore = awayScore then 1 end) draws " +
-            "FROM (SELECT * FROM SoccerResults WHERE homeTeam = " . $teamId . " AND " +
+            $sql = "SELECT count(case when homeScore > awayScore then 1 end) wins, " .
+            "count(case when awayScore > homeScore then 1 end) lost, " .
+            "count(case when homeScore = awayScore then 1 end) draws " .
+            "FROM (SELECT * FROM SoccerResults WHERE homeTeam = " . $teamId . " AND " .
             "HomeScore >= 0 AND awayScore >= 0 ORDER BY gameDate DESC LIMIT " . $numResults . ") as t";
         } else {
-            $sql = "SELECT count(case when homeScore < awayScore then 1 end) wins, " +
-            "count(case when awayScore < homeScore then 1 end) lost, " +
-            "count(case when homeScore = awayScore then 1 end) draws " +
-            "FROM (SELECT * FROM SoccerResults WHERE awayTeam = " . $teamId . " AND " +
+            $sql = "SELECT count(case when homeScore < awayScore then 1 end) wins, " .
+            "count(case when awayScore < homeScore then 1 end) lost, " .
+            "count(case when homeScore = awayScore then 1 end) draws " .
+            "FROM (SELECT * FROM SoccerResults WHERE awayTeam = " . $teamId . " AND " .
             "HomeScore >= 0 AND awayScore >= 0 ORDER BY gameDate DESC LIMIT " . $numResults . ") as t";
         }
         
-        return $mysql->getSqlAsArray($sql);
+        return $this->getSqlAsArray($sql);
     }
 }