Re: Usage of BD.php inside a class

From: Date: Sat, 14 Apr 2001 10:57:38 +0000
Subject: Re: Usage of BD.php inside a class
References: 1 2 3 4 5  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-53@lists.php.net to get a copy of this message
Thanks Marcus, I see.. this is far too complex for me. I was interested in pear because I wanted to make the sites I develop database independant.. I'll wait for the tutorials and doc to be ready (I'm not in such a hurry).. Thanks again for your time Luc At 06:06 14/04/01 +0200, Markus Fischer wrote:
        If you have
        class foobar {
                function somefunc() {
                        $db = DB::connect( 'blabla');
Then note that '$db' is local known to 'somefunc()' _only_ ! In this case $db != $this->db ! If you want to keep the handle known to the class, just assign it initially to $this->db :
        class myclass {
                function makeConnection() {
                        $this->db = DB::connect( '...');
                        .
                        .
                        $this->db->query( $sql);
                        .
                        .
If you call disconnect() in the same function anyway, you won't need the handle outside the function and can remove the $this-> reference anywhere.


« previous php.pear.general (#53) next »