I don't think you're doing this right.
What you should do is create a hierarchy: have a base DB
abstract class that defines common behavior applicable to all database types, then have a separate class for each database extend the base class. In other words, something like this:
abstract class DB {
public function __construct($host, $username, $password) {
$this->connect($host, $username, $password);
}
abstract public function connect($host, $username, $password);
abstract public function query($sql);
}
class MySQL extends DB {
public function connect($host, $username, $password) {
//...
}
public function query($sql) {
//...
}
}
Then, depending on which database you need, create an instance of the proper class:
if ($dbtype == 'mysql') {
$DB = new MySQL($host, $username, $password);
}
else if ($dbtype == 'mssql') {
$DB = new MySQL($host, $username, $password);
}
//...