Re: do pear packages create their own seperate DB connections?
| From: | Jeroen Houben | Date: | Tue, 22 Apr 2003 19:47:26 +0000 |
| Subject: | Re: do pear packages create their own seperate DB connections? | ||
| References: | 1 2 3 4 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-15348@lists.php.net to get a copy of this message | ||
>
> But to try to answer your question, I think what you want to do might
> be:
>
> if (do i need a DB-connection?) {
> $db = DB::connect();
> do DB stuff
> } else {
> get data/results or do action without
> the need of using db-data
> }
>
> i hope i could explain what i mean :-)
>
Yes it is, but I'm afraid *I* couldn't explain what *I* mean :-)
I'll take your example from above and change it to what I mean. Maybe what
I'd like to see is not possible but at least we'll be talking about the
same thing.
if (do i need a DB-connection?) {
if (there is an instance of (M)DB 'out there' for the given DSN) {
// use it
} else {
$db = DB::connect(DSN);
do DB stuff
}
} else {
get data/results or do action without
the need of using db-data
}
Hope that makes it clearer. I think Lukas mentioned this in one of his
posts tonight. Would it be difficult to find out of an instance for the
given DSN exists?
some problems I can see already:
- an instance of (M)DB for the same DSN might exists inside other objects
in which the instance is private.
- some options may have been set on the instance (like the fetchmode)
which could cause conflicts when used directly inside other packages.
Lukas, is something like this possible with MDB?
Jeroen