Really this is a best practices question...
I have many PHP objects. Many of the objects have internal DB objects... for example
class Connect {
// cool db wrapper
}
class uses_db {
function uses_db() {
$this->db=New Connect;
}
function use_the_db() {
$this->db->query("blah blah blah");
}
} // end class
However, and here is the question, isn't this bad practice? If I use 5 objects in a page, doesn't that mean I have 5 connections / DB objects? The DB wrapper uses pconnect() so it should use the open connections... it just strikes me as bad coding (plus memory wastage), but I don't want to force people to have to pass in a DB object... <sigh>
Thoughts, suggestions?
TIA
Steve