mam problem, ale pierw przedstawie skrypty:
game.php
<?php
require_once('mysql.php');
require_once('player.php');
require_once('website.php');
class Game {
function Game($getPlayerName) {
$this->PlayerName = $getPlayerName;
$this->SQL = new MySQL($this->PlayerName); $this->Player = new Player($this->PlayerName);
$this->Website = new Website($this->PlayerName);
}
}
?>
Najważniejszy jest player.php:
<?php
class Stats
extends MySQL { function getPercent($stat, $precision=0) {
$getStat = mysql_query(\"SELECT * FROM \".$this->prefix(0, \"player_stats\").\" WHERE user='\".$this->PlayerName.\"'\"); @$countPC = round(($_Stat[$stat]/$_Stat[$stat.'_max'])*100
, $precision);
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) {
}
}
class Player
extends MySQL { 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) {
if (@!mysql_connect($this->db_host, $this->db_user, $this->db_pass)) { } else {
$this->isConnected = true;
}
}
$this->PlayerName = $getPlayerName;
}
}
?>
I index.php, gdzie jest deklaracja:
<?php
require_once('includes/game.php');
if (!isset($_SESSION['member'])) { $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 ^.-
Ten post edytował EdeusEx 6.04.2008, 11:08:47