I am starting to work with PHP classes and have the following need:
I want to create a Class where I have 2 functions returning 1 array each. The 2 arrays can be used either withing the class (by other functions) or outside the class. How would I return the 3 arrays?
What I tried is to have other functions that just return the array value, so I can use it outside. Is this the most efficient way? Is there a better and quicker way to return my arrays independently?
So far I have something like this:
class playersData
{
private $players = array();
private $resultados = array();
public function myPlayers ()
{
return $this->players();
}
public function playersQuery
{
$query = "SELECT * FROM scoreboard";
$playersQuery = $con->prepare($query);
$playersQuery->execute();
$this->players = $playersQuery->fetchAll(PDO::FETCH_ASSOC);
}
function checkPartidos
{
$queryResultados = "SELECT * FROM partidos WHERE ganador <> 0";
$result = $con->prepare($queryResultados);
$result->execute();
$this->$resultados = $result->fetchAll(PDO::FETCH_ASSOC);
}