Hi, Thursday, July 31, 2003, 1:30:54 AM, you wrote: amc> Hello,
amc> I'm lookin for some tips on the best way to do this... amc> I make a database connection outside of my classes... lets call it amc> $myDBConnection. I need to use this connection in a class nested in a amc> class... Was wondering the most efficient way of doing this? I don't want to amc> create a new db connection in the class. I want to use the existing one... amc> If no one has a better Idea I'll pass the connection through the constructor amc> of the first class, and then again into the constructor of the nested amc> class... then I can query and use the database connection as $this->>myDBConnection.... Just wanted to avoid that because there's about 5 amc> db connections I'll have to pass in... amc> Any thoughts? Would it make things easyer if the base class inherited all amc> nested classes instead of nesting them? amc> Any help would be appreciated. amc> Thanks amc> -Dennis what I do is have a global array of classes and register each class like this: class a { function a(){ global $classes; $classes['a'] =& $this; } } class b { var $a; function b(){ global $classes; if(isset($classes['a'])){ this->a =& $classes['a']; }else{ $this->a = new a(); } } } -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php