|
Down Rodeo said: tells the program you want to access the method FindWorlds from $world?
php code <?php require_once 'database.php';
// all we need to do is display, get, or set data class World { public $id; public $name; public $description; public $threads; public $lastPost; public $numberOfCategories; public function __construct($inId=null, $inName=null, $inThread=null, $inLastPost=null) { $this->id = $inId; $this->name = $inName; $this->thread = $inThread; $this->lastPost = $inLastPost; } /* * Determine the amount of worlds */ public function FindWorlds() { //$database = new Database(); //$countRowsConnect = $database->ConnectToDatabase("general"); $countRowsConnect= mysql_connect("127.0.0.1","general","g-g-g-godlike"); mysql_select_db("general"); $countRows = mysql_query("SELECT `id` FROM `world`"); $this->numberOfCategories = mysql_num_rows($countRows); //mysql_free_result($countRows); //mysql_close($countRowsConnect); return $this->numberOfCategories; } /* * Get data from mysql */ public function GetData($worldId) { //connect to mysql //$database = new Database(); //$getDataConnect = $database->ConnectToDatabase("general"); $getDataConnect= mysql_connect("127.0.0.1","general","g-g-g-godlike"); mysql_select_db("general"); $getData = mysql_query("SELECT * FROM `world` WHERE `id`='$worldId'"); $Data = mysql_fetch_assoc($getData); $this->id = $Data['id']; $this->name = $Data['name']; $this->description = $Data['description']; $this->lastPost = $Data['most recent']; //mysql_free_result($getData); //mysql_close($getDataConnect); // Get most recent post information (name, time, etc) $this->lastPost = $this->GetMostRecent($this->id); // Get number of threads $this->threads = $this->GetThreads($this->id); return true; } /* * Set data, does not modify mysql */ public function SetData() { } /* * Sets data, modifies general.world */ public function Update() { } /* * Display data, must call GetData first, otherwise the function will return false */ public function DisplayWorld() { // if we don't make sure we call getdata we cannot display anything! if( empty($this->id) || empty($this->name) || empty($this->description) || empty($this->threads) || empty($this->lastPost) ) { return false; } else { return true; } } private function GetMostRecent($worldId) { $mostRecentQuery = mysql_query("SELECT `most recent` FROM `world` where id=$worldId"); $mostRecent = mysql_fetch_assoc($mostRecentQuery); $mostRecentPost = $mostRecent['most recent']; $mostRecentData = mysql_query("SELECT * FROM region WHERE world=$worldId ORDER BY date DESC"); $final = mysql_fetch_assoc($mostRecentData); return $final['poster'] . "," .$final['date']; } private function GetThreads($worldId) { $threadsQuery = mysql_query("SELECT id FROM region WHERE world=$worldId"); return mysql_num_rows($threadsQuery); } public function __destruct() { // Dark ages? (celestial year 60ish?) } } // end class world
// moar code less comments! class Land { } // end class land
class Region { } // end class region
?>
|
|
|
|
≡
|
2010 Dec 4 at 23:36 UTC
— Ed. 2010 Dec 4 at 23:37 UTC
|
|