game.php
<?php require_once('mysql.php'); require_once('player.php'); require_once('website.php'); class Game { function Game($getPlayerName) { $this->PlayerName = $getPlayerName; $this->Player = new Player($this->PlayerName); $this->Website = new Website($this->PlayerName); } } ?>
Najważniejszy jest player.php:
<?php function getPercent($stat, $precision=0) { $getStat = mysql_query(\"SELECT * FROM \".$this->prefix(0, \"player_stats\").\" WHERE user='\".$this->PlayerName.\"'\"); return $countPC; } function getValue($stat) { $getStat = mysql_query(\"SELECT * FROM \".$this->prefix(0, \"player_stats\").\" WHERE user='\".$this->PlayerName.\"'\"); return $_Stat[$stat]; } function changeValue($stat) { } } function Player() { $this->EQ = new Equipment($this->PlayerName); $this->Stats = new Stats($this->PlayerName); $this->Account = new Account($this->PlayerName); $this->Messages = new Messages($this->PlayerName); $this->Guild = new Guild($this->PlayerName); } } ?>
mysql.php
<?php public $PlayerName = \"\"; function __construct($getPlayerName) { if ($this->isConnected==false) { } else { $this->isConnected = true; } } $this->PlayerName = $getPlayerName; } } ?>
I index.php, gdzie jest deklaracja:
<?php require_once('includes/game.php'); $setPlayerName = 'guest'; } else { $setPlayerName = $_SESSION['member']; } $Game = new Game($setPlayerName); ?>
Dlaczego, wywołując $Game->Player->Stats->getValue('blabla'); $this->PlayerName nie ma żadnej wartości? Gdzieś zgubiłem przekazywanie ^.-