DB Class pointer as var in another class

From: Date: Thu, 14 Mar 2002 17:47:12 +0000
Subject: DB Class pointer as var in another class
Groups: php.db 
Request: Send a blank email to php-db+get-17688@lists.php.net to get a copy of this message
We've been considering the following implementation of a class pointer within another class. Our goal here is to minimize the number of database connections per function call. It seems to work just fine, but I wanted to post this up for comments. PHP 4.1.1 doesn't seem to have a problem with it. We have a couple classes working this way in some of our beta code. I've never seen anyone do this before so I just wanted to make sure we weren't wandering into uncharted waters. class my_class { var $test; var $db_class; function my_class($test) { $this->test = $test; $this->db_class = new database_class(DB_NAME); } function get_db_info() { ... use db here via $this->db_class ... } } Thanks, Gary

« previous php.db (#17688) next »