RE: [PEAR-DEV] do pear packages create their own seperate DB connections?
| From: | Lukas Smith | Date: | Tue, 22 Apr 2003 15:36:23 +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-15338@lists.php.net to get a copy of this message | ||
> From: Wolfram Kriesing [mailto:wolfram@visionp.de]
> Sent: Tuesday, April 22, 2003 5:33 PM
> Lukas Smith wrote:
> >>From: Wolfram Kriesing [mailto:wolfram@visionp.de]
> >>Sent: Tuesday, April 22, 2003 5:12 PM
> >
> >
> >>now i dont have to instanciate the DB myself, since i dont really
need
> >>it. Only the packages i use need the DB-connection. I actually use
> >>only 3 packages that need a DB-connection (iirc) Auth, Tree,
> >>DB_QueryTool. To those packages i simply pass the DB_DSN and they
> >>(should) handle themselves if/when they need a DB-connection.
> >
> >
> > Hmm well to me there are two things that might create overhead here:
> >
> > 1) object creation
> > 2) connection establishing
> >
> > 2) does not exist in MDB as the connection is created on demand with
the
> > first query. So if you simply always create an MDB object which you
then
> > pass to any package you use, the only overhead you have in the case
you
> > don't need a Db connection is the MDB object creation.
> >
> > I don't really understand how standard PEAR packages should be able
to
> > figure out if you have an instance of a certain package from global
> > space without a total mess? I am probably misunderstanding what you
are
> > proposing here.
>
> yeah i think 1) could be overhead
> either
> i) you accept it (or there is a solution to prevent it)
> or
> ii) may be [M]DB could/should have a mode which returns always the
> same instance for one DSN, which of course could cause problems when
> you depend on [M]DB internal states
I am no expert in the pattern buzz word bingo game .. but it would very
well be possible to write a "singleton" pattern in MDB that would
require no modification in the other packages.
MDB already maintains an array of all existing MDB instances. This array
could be traversed before creating a new instance.
Regards,
Lukas