Reply to Object Scope

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация