Re: Global variables in a class? Nested classes VS inheritance...
| From: | Brent Westmoreland | Date: | Thu, 18 Mar 2004 00:00:47 +0000 |
| Subject: | Re: Global variables in a class? Nested classes VS inheritance... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-180776@lists.php.net to get a copy of this message | ||
I too have questions on how to handle this situation, any help would be greatly appreciated.
On 2003-07-30 11:30:54 -0400, anachronism@mengelt.com said:
Hello, I'm lookin for some tips on the best way to do this... I make a database connection outside of my classes... lets call it $myDBConnection. I need to use this connection in a class nested in a class... Was wondering the most efficient way of doing this? I don't want to create a new db connection in the class. I want to use the existing one... If no one has a better Idea I'll pass the connection through the constructor of the first class, and then again into the constructor of the nested class... then I can query and use the database connection as $this->myDBConnection.... Just wanted to avoid that because there's about 5 db connections I'll have to pass in... Any thoughts? Would it make things easyer if the base class inherited all nested classes instead of nesting them? Any help would be appreciated. Thanks -Dennis