NYCPHP Meetup

NYPHP.org

[nycphp-talk] database handles

Daniel Convissor danielc at analysisandsolutions.com
Thu Sep 30 22:57:02 EDT 2004


On Thu, Sep 30, 2004 at 08:27:22PM -0400, Matthew Terenzio wrote:

> This seems to work fine. I just feel funny about having classes lying 
> around which rely on another class having been instantiated somewhere 
> upwards on a page.
> 
> Will using Pear DB,  if you call DB:: connect() twice on a page, will 
> it open two connections to the database?

The first way is the way to go.  Having multiple connection attempts is 
inefficient.  If you want flexibility of potentially not having the 
prior objects loaded, have the subsequent objects do a check if DB is 
instantiated or not.  If not, then instantiate it.

--Dan

-- 
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
            data intensive web and database programming
                http://www.AnalysisAndSolutions.com/
 4015 7th Ave #4, Brooklyn NY 11232  v: 718-854-0335 f: 718-854-0409



More information about the talk mailing list