Re: Re: DB: Changing database during script execution

From: Date: Mon, 22 Jul 2002 16:43:48 +0000
Subject: Re: Re: DB: Changing database during script execution
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-7864@lists.php.net to get a copy of this message
Lukas Smith wrote: > > > I don't want to pass a new DSN, I just want to (temporarily) use > > another database. Thus disconncting and opening a new connection is > not > > necessary. What about > > > > function pushDatabase($db = '') { > > array_push($this->_db_stack, $this->_db); > > $this->_db = $db; > > } > > > > function popDatabase() { > > $this->_db = array_pop($this->_db_stack); > > } > > > > (Above code is not tested and surely not very well thought, but it > > should give you the idea.) > > > > With this functions one has the chance to switch between different > > databases during execution time just like he can switch between error > > modes via PEAR::pushErrorHandler() and PEAR::popErrorHandler(). Do you > > think this makes sense and can be applied to all other database > systems > > than MySQL? > > > > - Martin > > > > MDB has setDatase($dbname) > This method returns the old method and sets the database to $dbname. Yeah, which basically does a disconnect() and connect(), the same I propossed to Martin (note that I'm talking about the drivers in general not MySQL specificly). > BTW: MDB (as does Metabase) only connects on demand. This one is interesting, but I would like to hear other ways for implementing it than testing for a connection in all the methods. Tomas V.V.Cox

« previous php.pear.dev (#7864) next »