RE: [PEAR-DEV] Re: DB: Changing database during script execution

From: Date: Mon, 22 Jul 2002 15:36:15 +0000
Subject: RE: [PEAR-DEV] Re: DB: Changing database during script execution
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-7857@lists.php.net to get a copy of this message
> 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. BTW: MDB (as does Metabase) only connects on demand. Best regards, Lukas

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