protected function validateDatabaseSettings(OutputInterface $output, InputInterface $input)
{
try {
$dsn = sprintf("mysql:host=%s;port=%s", $this->config['db_host'], $this->config['db_port']);
$db = new PDO($dsn, $this->config['db_user'], $this->config['db_pass']);
if (!$db->query('USE ' . $this->config['db_name'])) {
$db->query("CREATE DATABASE `" . $this->config['db_name'] . "`");
$output->writeln('<info>Created database ' . $this->config['db_name'] . '</info>');
$db->query('USE ' . $this->config['db_name']);
return $db;
}
} catch (PDOException $e) {
$output->writeln('<error>' . $e->getMessage() . '</error>');
return false;
}
if ($input->getOption('noDownload') && !$input->getOption('forceUseDb')) {
$output->writeln(sprintf("<error>Database '%s' already exists, use --forceUseDb in combination with --noDownload" . " to use an existing database</error>", $this->config['db_name']));
return false;
}
return $db;
}