Re: DB request

From: Date: Tue, 14 May 2002 12:16:14 +0000
Subject: Re: DB request
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-1369@lists.php.net to get a copy of this message
Combined with lazy [re]connects, it would be pretty straightforward to use it too. I like it, will implement in the next DB release. - Stig On Tue, 2002-05-14 at 13:14, Sam Liddicott wrote: > It can be expensive to keep a DB connection open while the user downloads a > long page generated by a report of that page. > We have this case, the reports are very inexpensive, but it takes a long > time for the page to be downloaded. > I would like to disconnect the DB while this happens and then (without > hassle) connect again on-demand if I need to use that connection again. > > In DB/pgsql.db > > function connect($dsninfo, $persistent = false) > { > if (!DB::assertExtension('pgsql')) > return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND); > > $this->dsn = $dsninfo; > ... > > We see that after one connection $dsninfo is stored in $this->dsn. > > So why does dsninfo need to be passed on a second call to connect? > > Why not: > function reconnect() > { > if (!DB::assertExtension('pgsql')) > return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND); > > if ($this->dsn===false) return $this->raiseError(DB_NOT_CONNECTED); > if ($this->connection) $this->disconnect(); > return $this->connect($this->dsn); > } > > Thus reconnect can be called without parameters to reconnect. > Then for each function we can have as the first line: > if (! $this->connection) $this->reconnect(); > > Which means the DB connects on demand, reconnects on demand etc. > > Of course to solve my problem I'll do it the hard way finding all the places > that might need to use DB and reconnecting there... > > But this I feel would add to PEAR DB > > Sam > _____ > > > Samuel Liddicott > Support Consultant > sam@ananova.com <mailto:sam@ananova.com> > Direct Dial: +44 (0)113 367 4523 > Fax: +44 (0)113 367 4680 > Switchboard: +44 (0)113 367 4600 > > Ananova Limited > Marshall Mill > Marshall Street > Leeds > LS11 9YJ > > http://www.ananova.com > > Registered Office: > St James Court > Great Park Road > Almondsbury Park > Bradley Stoke > Bristol BS32 4QJ > Registered in England No.2858918 > > The information transmitted is intended only for the person or entity to > which it is addressed and may contain confidential and/or privileged > material. Any review, retransmission, dissemination or other use of, or > taking of any action in reliance upon, this information by persons or > entities other than the intended recipient is prohibited. If you receive > this in error, please contact the sender and delete the material from any > computer. > > > > >

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