Forum Moderators: coopster
Right now, each class creates a db object in its constructor. I'm assuming that's a bad idea, since we wind up with 4 or 5 db connections for each page. I'd like to make one db class that escapes all the query data and forms nice queries.
But should I create the db object and then pass that object into each class? ( something like:
$useful_object = new Thing_Creator($db_abstraction_object)
)
Or is there another approach for integrating these db abstraction layers into a large code base?
A short rundown if you're unaware what a static method does is, it allows you to call a class method without creating a whole object.
You would declare the method as such -
class dbAbstraction {
public static function dbConnect(){
// code to connect here
}
}
Then you can call this method from another class like this: dbAbstraction::dbConnect();
If you already had some knowledge in this method, I hope this helps, if you need more assistance, feel free to let me know and I'll get back to this topic with a more thorough explanation