N98\Magento\Command\Installer\InstallCommand::validateDatabaseSettings PHP Метод

validateDatabaseSettings() защищенный Метод

protected validateDatabaseSettings ( Symfony\Component\Console\Output\OutputInterface $output, Symfony\Component\Console\Input\InputInterface $input ) : boolean | PD\PDO
$output Symfony\Component\Console\Output\OutputInterface
$input Symfony\Component\Console\Input\InputInterface
Результат boolean | PD\PDO
    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;
    }