Use of Class Reference Variable in another Class

From: Date: Wed, 04 Feb 2004 13:46:44 +0000
Subject: Use of Class Reference Variable in another Class
Groups: php.general 
Request: Send a blank email to php-general+get-176790@lists.php.net to get a copy of this message
Inside of a class I am trying to make a call to a function in another class. I have one class defined to be my DataBase Interface call "dbi". To use that class I do this: $db = new dbi; Then I can use the functions in "dbi" like this: $db->dbquery("select * from whatever"); Inside another class (Class2) I have several functions that need database access. So in each function I can use "$db = new dbi;" and then use the functions as usual ($db->dbquery("blah");). I am wondering, can I create the new "dbi" instance at the top of Class2 and have all the functions within Class2 use the "dbi" class reference variable ($db)? If so, would the use be something like this: $this->db->dbquery("blah"); Thank you, Jonathan Duncan www.jkdwebmagic.com Web Site Hosting and Design

« previous php.general (#176790) next »