DB singleton function?
| From: | Joe Stump | Date: | Tue, 26 Oct 2004 21:02:54 +0000 |
| Subject: | DB singleton function? | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-34085@lists.php.net to get a copy of this message | ||
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];
}
--Joe
--
Joe Stump, PHP Developer
http://www.joestump.net
How would this sentence be different if pi equaled 3?