Re: DB singleton function?
| From: | Joe Stump | Date: | Tue, 26 Oct 2004 22:41:38 +0000 |
| Subject: | Re: DB singleton function? | ||
| References: | 1 2 3 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-34088@lists.php.net to get a copy of this message | ||
I don't want to use MDB2.
--Joe
> Ian Eure wrote:
>> On Tuesday 26 October 2004 02:02 pm, Joe Stump wrote:
>>
>>>Why isn't there a DB singleton function like there is in Log? It would
>>> be
>>>extremely simple to implement and could be used when PHP5 finally
>>> becomes
>>>standard.
>>>
>>>Ie.
>>>
>>> function &singleton ($dsn)
>>> {
>>> if (!isset($GLOBALS['_DB_Connections'][$dsn])) {
>>> $GLOBALS['_DB_Connections'][$dsn] = & DB::connect($dsn);
>>> }
>>>
>>> return $GLOBALS['_DB_Connections'][$dsn];
>>> }
>>>
>>
>> I was wondering this a while back, and I was going to work something up.
>> I
>> wasn't sure if singleton() should try to connect(), or just call
>> factory().
>> Connecting seems like the right thing, but I think there's an assumption
>> that
>> singleton() will work like factory(), e.g. not connect. And
>> connectSingleton() seemed like a pretty bad function name.
>>
>> Any DB developers have feedback on this issue?
>
> Have a look at MDB2.
> You probably want a singleton per DSN.
>
> regards,
> Lukas
>
> --
> PEAR Development Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Joe Stump, PHP Developer
http://www.joestump.net
How would this sentence be different if pi equaled 3?