I have a situation where one of my classes are getting way too big. It's used for a forum and its methods are responsible for writing various parts of it, i.e.
Code: Select all
$_SESSION["board"]->WriteHeader()
$_SESSION["board"]->WriteNavigation()I am now working on a messaging part, and contemplating making a class for it specifically, so I'd get something like:
Code: Select all
$msg = new Message();
$msg->senderID = $senderID;
$msg->message = $message;
$msg->Dispatch();If I have something like:
Code: Select all
class Message{
var $mysql;
var $conn;
function Message($mysql,$conn,$other){
$this->mysql = $mysql;
$this->conn = mysql_connect ...
}
}Code: Select all
class Message{
var $privatevar1;
var $privatevar2;
function Message(&$msg){
$this->message= $msg;
$this->messageID = $_SESSION["board"]->Query("SELECT `id` FROM `table`");
$_SESSION["board"]->Query("INSERT INTO `msg` (`message`) VALUES ('$msg' WHERE `id`=".$this->userID.")");
}
}I think I made a mistake putting the mysql stuff into the main board object and not standalone, but sofar it hasn't been a problem.
Any suggestions are welcome.
Thanx,
H
}