Re: Static Member Variables holding objects w/methods
| From: | Gabe | Date: | Wed, 16 Aug 2006 21:24:10 +0000 |
| Subject: | Re: Static Member Variables holding objects w/methods | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-240790@lists.php.net to get a copy of this message | ||
Richard Lynch wrote:
On Wed, August 16, 2006 9:13 am, Gabe wrote:Actually I found that I should use this notation: self::$connector->Close(); And my class method wasn't static. So I couldn't access the static member. Details, details.... =)I'm trying to use the following method of a class (DbConnector): public function closeConnector() {What is $connector ??? Perhaps you want DbConnector::connector// echo "<p>in closeConnector()"; var_dump(DbConnector::$connector);Try it without the $ If that's not it, try: $connector = DbConnector::$connector; $connector->Close(); Sometimes PHP is not so good at -> chasing down a tree... Or, at least, it used to be not so good at that... I suspect that's been fixed for ages, but worth a shot.echo "</p>";//make sure the db object is cleaned up properly if ( gettype(DbConnector::$connector) == 'object' ) { echo "<br><br>close the ADOdb connection<br><br>"; DbConnector::$connector->Close();}//put things back the way they were found $this->connector = false; }DbConnector is meant to be a singleton class that manages an ADOdb object. However, when the code executes and it gets to this line: DbConnector::$connector->Close(); the script fails and says "Call to undefined method DbConnector::Close()" Is trying to call the Close() method of the static member var (which holds an ADOdb object) not possible? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php