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



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to