RE: [PEAR-DEV] do pear packages create their own seperate DB connections?

From: Date: Wed, 23 Apr 2003 15:06:49 +0000
Subject: RE: [PEAR-DEV] do pear packages create their own seperate DB connections?
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-15391@lists.php.net to get a copy of this message
> From: Hans Lellelid [mailto:hans@appliedsec.com] > Sent: Wednesday, April 23, 2003 4:51 PM > Jeroen Houben wrote: > > >Hi Lukas, > > > >Sorry if I'm "over-discussing" this topic, but isn't this > >(http://www.horde.org/papers/kongress2002-design_patterns/) exactly what > >you're looking for for MDB? > >the example on the bottom of the page shows you can have more instances > of > >one class depending on the passed parameters. If a package requests an > >instance of MDB it will check if such an instance with the same > paramaters > >(like the DSN) exists and if it does it will return a reference to that > >one. If not, it will create a new instance. > >HTH > > > > I would wonder how much overhead this will really save.... If you call > MDB::connect() with the same params as an existing connection the native > PHP database functions will not create a new connection (right...?) but > simply return the resource ID for the existing db connection. So at > some level PHP is already doing 'singleton' stuff at the db level. > > What will be saved is the creation of a new MDB class that wraps that db > connection. I do think this would be a nice addition, but I'm not sure > that the performance gains would be great. (would love to be wrong, > though, as I use MDB on several projects -- and could benefit from a > singleton() pattern.) Well I am pretty sure it will safe overhead. Not sure how much though. There are some obvious benefits however as I have mentioned before. One being the debugging. MDB can store all queries run through it. This is quite nice to find the bottlenecks. The handler is freely defineable so you could probably extend it to automatically run "EXPLAIN" queries etc. The cool thing with a singleton is that you could not also see the true order in which queries are processed. Another advantage is the reducing of memory overhead. Anyways it seems nobody is reporting any issues with the last MDB release. So I am about to release it. Then I will implement the singleton pattern. Regards, Lukas

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