Witam, ucze sie programowania obiektowego i mam problem z przekazaniem tablicy. Postanowilem napisac prosty typer sportowy:
class zaklad {
public $db;
function __construct() {
$class = "baza";
$path = "{$class}.php";
throw new Exception("Brak pliku {$path}");
}
require_once($path);
if (!class_exists($class)) {
throw new Exception("Brak klasy {$class}");
}
$this->db = new baza();
}
function getAllBets() {
if ($this->db->connect()) {
if ($results = $this->db->select("SELECT * FROM typer_main")) {
$returned[] = array('zid' => $row['ZID'], 'text' => $row['Text'],
'res_x' => $row['Res_x'],
'res_y' => $row['Res_y'],
'kategoria' => $row['Kategoria'],
'data' => $row['Data'],
'status' => $row['Status']
);
}
return $returned;
} else {
echo "Błąd pobrania danych " . $this->db->error; return false;
}
$this->db->close();
} else {
echo "błąd połączenia z bazą danych: " . $this->db->error; return false;
}
}
function showAllBets() {
}
}
jezeli wyswietlam tablice returned z metody getAllBets wszystko jest ok. Chcialbym jednak przekazac ją do metody show w celu formatowania jej wygladu. Jak mozna to zrobic ? Kod z pliku index:
$class = "zaklad";
$path = "{$class}.php";
require_once($path);
} else {
throw new Exception("Brak pliku {$path}");
}
if (class_exists($class)) {
$bet = new zaklad();
$bet->showAllBets();
}
Pozdrawiam