Re: Class within a class
| From: | Leif K-Brooks | Date: | Mon, 10 Feb 2003 19:56:54 +0000 |
| Subject: | Re: Class within a class | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-135111@lists.php.net to get a copy of this message | ||
If the DB object is already a global, like you seem to be saying, then you're already using globals...
Justin Mazzi wrote:
Is there anyway to do this without using globals? -----Original Message----- From: Leif K-Brooks [mailto:eurleif@buyer-brokerage.com] Sent: Monday, February 10, 2003 2:46 PM To: Justin Mazzi Cc: php-general@lists.php.net Subject: Re: [PHP] Class within a class Use $GLOBALS['db'] (or whatever the variable name of the global variable is). Justin Mazzi wrote:-- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.I have made a Mysql database class. I wanted to know how I could use that class in another class without using extend. For example: include 'db.php'; $db = new db(); ...some php code... class blah { var $test = 1; function blah() { ...... $db->query(some query); //mysql class being used here } } I don't want to create an instance of db class in the blah classbecauseI use db in other parts of the script so an instance already exists.Anyway I can do this?