Re: do pear packages create their own seperate DB connections?

From: Date: Tue, 22 Apr 2003 20:09:03 +0000
Subject: Re: do pear packages create their own seperate DB connections?
References: 1 2 3 4 5  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-15349@lists.php.net to get a copy of this message
Jeroen Houben wrote:
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
yes, Lukas mentioned it. It's the singleton ... and he wrote that he is thinking about putting it into MDB what i do in my appls is the following to implement the singleton class x {
    function &getInstance()
    {
        $varName = '__'.__CLASS__;
        if (!isset($GLOBALS[$varName]) ||
            get_class($GLOBALS[$varName])!=__CLASS__) {
            $GLOBALS[$varName] =& new x();
        }
        return $GLOBALS[$varName];
    }
} this way it gets saved in the global namespace, i know. its not really cool. but may be someone knows a better and nicer way or is it even simpler with php4? -- Wolfram http://opensource.visionp.de ... authentication system .... http://sf.net/projects/auth

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