Global variables in a class? Nested classes VS inheritance...
| From: | anachronism at mengelt dot com | Date: | Wed, 30 Jul 2003 15:30:54 +0000 |
| Subject: | Global variables in a class? Nested classes VS inheritance... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-157532@lists.php.net to get a copy of this message | ||
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