Unless you need multiple database connections then the "best" way is to simply have one global $db connection variable.
class Whatever
{
function need_some_data()
{
global $db;
// whatever
}
}
I come from a C/C++ background where globals are frowned upon. But because php requires you to explicitly state that a variable is global, I find that they work ok when used in moderation.
But maybe you need multiple connections. In that case, I would assume that each of your classes derives from a base class. The base class constructor is where the connection would be opened.
I would suggest that the base class constructor load in default values for dbhost,username etc. from a config file. The base constructor would have an argument for an array which could be used to override the default values if necessary.
Thus, the individual classes would only need to set those values which need to be overridden.