在PHP中的同一个类中使用另一个函数中的函数

时间:2014-07-01 21:37:25

标签: php function class call

我有一个包含2个函数的类。我想在其他函数中使用其中一个函数。两个公共职能。这可能吗?我无法让它发挥作用。

这是我的班级:

class scores {
    public function rightScoreTicks($idMatch, $currentScores)
    {
        include('commonItems/connectionMundial.php');   
        $rightScores = "SELECT * FROM partidos WHERE ganador <> 0 AND id = ".$idMatch;
        $resultRight = $con->prepare($rightScores);
        $resultRight->execute();
        $rightScore = $resultRight->fetchAll();

        if ($rightScore[0]['ganador'] != 0)
        {
            //echo " | (Resultado final: ".$rightScore[0]['score1']." - ".$rightScore[0]['score2'].")";
            if ($rightScore[0]['ganador'] == $currentScores[0]['ganador'])
            $rightProno = "<font style='color: green;'><strong>&#10004;</strong></font>";
            else $rightProno = "<font style='color: red;'><strong>&#x2718;</strong></font>";
            if ($rightScore[0]['score1'] == $currentScores[0]['team1'] && $rightScore[0]['score2'] == $currentScores[0]['team2'] )
            $exactScore = "<font style='color: green;'><strong>&#10004;</strong></font>";
            else $exactScore = "<font style='color: red;'><strong>&#x2718;</strong></font>";
            echo "  ".$rightProno." ".$exactScore;
        }
    }

    public function allPlayersProno ($idMatch, $idPlayer2, $bettingActive)
    {

        include('commonItems/connectionMundial.php');   
        $allpron = "SELECT * FROM predictions WHERE id_partido = ".$idMatch;
        $allPronos = $con->prepare($allpron);
        $allPronos->execute();
        $allPronosticos = $allPronos->fetchAll();

        foreach ($allPronosticos as $eachProno)
        {       
            $playerName2 = playerDetails($eachProno['id_usuario']);
            if ($eachProno['ganador'] != 0 && $eachProno['id_usuario'] != $idPlayer2)
            {
                echo "<br><span style='font-size: 12px; color: #0F753F;'>".$playerName2.": ".$eachProno['team1']." - ".$eachProno['team2'];
                $this->rightScoreTicks($comingMatch['id'], $pronoJugad);
                echo "</span>";
            }
        }
    }
}

我在函数allPlayersProno中尝试$this->rightScoreTicks($comingMatch['id'], $pronoJugad);

0 个答案:

没有答案