Object Scope

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux