Re: Use of Class Reference Variable in another Class

From: Date: Wed, 04 Feb 2004 16:01:00 +0000
Subject: Re: Use of Class Reference Variable in another Class
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-176803@lists.php.net to get a copy of this message
news.php.net wrote: >[snip...] > >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)? > > Yes, you can. >If so, would the use be something like this: > >$this->db->dbquery("blah"); > > No need. Just $db->dbquery("blah"), as you did in each separate function, since it is now seeable by all the functions inside the class2. Best Bao >Thank you, >Jonathan Duncan >www.jkdwebmagic.com >Web Site Hosting and Design > > >

« previous php.general (#176803) next »