protected function makeMysqlCommand($class, $credentials, $query = null)
{
$mysqlCommand = new $class($credentials['database']);
if (!empty($credentials['server'])) {
$mysqlCommand->host = $credentials['server'];
}
if (!empty($credentials['user'])) {
$mysqlCommand->user = $credentials['user'];
}
if (!empty($credentials['password'])) {
$mysqlCommand->password = $credentials['password'];
}
if (!empty($credentials['port'])) {
$mysqlCommand->port = $credentials['port'];
}
if ($query) {
$mysqlCommand->query = $query;
}
return $mysqlCommand;
}