[thelist] PHP MySQL Connections

Maximillian Schwanekamp lists at neptunewebworks.com
Thu Jan 27 16:47:32 CST 2005

I'm still pretty new to OOP in PHP, so be easy on me:  I am wondering 
about the [in]efficiency of multiple MySQL connections.

Using PHP 4.3.10, MySQL 4.0.something...  I have multiple objects, each 
of which instantiates a MySQL connection object - i.e. something like this:
// in class A constructor fn, objDB is instantiated, and relevant
// data is pulled
objA =& new A;

// objA::create_form instantiates instantiates objForm
// objForm itself instantiates its own objDB connection
// to look up form fields
// according to current session/user state

// objA::display_page() instantiates objTemplate to display the page
// objTemplate *also* has its own objDB connection (pulling data for
// nav menu items, banner ad, etc

So my question is, from the perspective of execution time, is this going 
to be much less efficient than say, passing a reference to a single DB 
object between the different objects?

Hopefully I am not being overly vague!  (Flame at will if so!)

Maximillian Von Schwanekamp
Dynamic Websites and E-Commerce
NeptuneWebworks.com <http://www.neptunewebworks.com/>
voice: 541-302-1438
fax: 208-730-6504

More information about the thelist mailing list