|
Posted by Chuck Brockman on 09/06/05 18:06
What is the best practice for calling objects that are to be used
throughout a users site visit. For example, I have a members class
with two classes that extend this class. Is it best to instantiate
the object in the $_Session scope or make individual calls to the
class/object.
For example:
class members {
var $iMemberID;
var $iProfileID;
var $dbServer;
var $dbUser;
var $dbPassword;
var $dbDSN;
var $_dbServer;
var $_dbUser;
var $_dbPassword;
var $_dbDSN;
function members($dbServer, $dbUser, $dbPassword, $dbDSN){
$this->_dbServer = $dbServer;
$this->_dbUser = $dbUser;
$this->_dbPassword = $dbPassword;
$this->_dbDSN = $dbDSN;
}
}
I have created a _global.php file that instantiates the object such as:
if(!isset($_SESSION["objMember"])){
$_SESSION["objMember"] = new members($aSiteSettings["sDBServer"],
$aSiteSettings["sDBLogin"], $aSiteSettings["sDBPassword"],
$aSiteSettings["sDSN"]);
}
Or am I way off base altogether (wouldn't be too suprises)?
Thanks!
[Back to original message]
|