protected function tryConnection($connectionInfo, OutputInterface $output)
    {
        if (\is_null($connectionInfo["dbName"])) {
            return false;
        }

        $dsn = "mysql:host=%s;port=%s";

        try {
            $connection = new \PDO(
                sprintf($dsn, $connectionInfo["host"], $connectionInfo["port"]),
                $connectionInfo["username"],
                $connectionInfo["password"]
            );
            $connection->query('SET NAMES \'UTF8\'');
        } catch (\PDOException $e) {
            $output->writeln(array(
                "<error>Wrong connection information</error>"
            ));

            return false;
        }

        return $connection;
    }
protected function tryConnection($connectionInfo, OutputInterface $output)
    {
        if (\is_null($connectionInfo["dbName"])) {
            return false;
        }

        $dsn = "mysql:host=%s;port=%s";

        try {
            $connection = new \PDO(
                sprintf($dsn, $connectionInfo["host"], $connectionInfo["port"]),
                $connectionInfo["username"],
                $connectionInfo["password"]
            );
            $connection->query('SET NAMES \'UTF8\'');
        } catch (\PDOException $e) {
            $output->writeln(array(
                "<error>Wrong connection information</error>"
            ));

            return false;
        }

        return $connection;
    }
protected function tryConnection ( $ connectionInfo , OutputInterface $ output ) { if ( \ is_null ( $ connectionInfo [ "dbName" ] ) ) { return false ; } $ dsn = "mysql:host=%s;port=%s" ; try { $ connection = new \ PDO ( sprintf ( $ dsn , $ connectionInfo [ "host" ] , $ connectionInfo [ "port" ] ) , $ connectionInfo [ "username" ] , $ connectionInfo [ "password" ] ) ; $ connection -> query ( 'SET NAMES \'UTF8\'' ) ; } catch ( \ PDOException $ e ) { $ output -> writeln ( array ( "<error>Wrong connection information</error>" ) ) ; return false ; } return $ connection ; }
test database access

@param $connectionInfo
@param  OutputInterface $output
@return bool|\PDO
test database access