Command/InstallCommand.php
private function isDatabaseExist()
    {
        $databaseName = $this->getContainer()->getParameter('database_name');

        try {
            /** @var MySqlSchemaManager $schemaManager */
            $schemaManager = $this->getContainer()->get('doctrine')->getManager()->getConnection()->getSchemaManager();
        } catch (\Exception $exception) {
            $message = "SQLSTATE[42000] [1049] Unknown database '%s'";
            if (false !== strpos($exception->getMessage(), sprintf($message, $databaseName))) {
                return false;
            }

            throw $exception;
        }

        try {
            return in_array($databaseName, $schemaManager->listDatabases());
        } catch(\PDOException $e) {
            return false;
        }
    }
private function isDatabaseExist()
    {
        $databaseName = $this->getContainer()->getParameter('database_name');

        try {
            /** @var MySqlSchemaManager $schemaManager */
            $schemaManager = $this->getContainer()->get('doctrine')->getManager()->getConnection()->getSchemaManager();
        } catch (\Exception $exception) {
            $message = "SQLSTATE[42000] [1049] Unknown database '%s'";
            if (false !== strpos($exception->getMessage(), sprintf($message, $databaseName))) {
                return false;
            }

            throw $exception;
        }

        try {
            return in_array($databaseName, $schemaManager->listDatabases());
        } catch(\PDOException $e) {
            return false;
        }
    }
private function isDatabaseExist ( ) { $ databaseName = $ this -> getContainer ( ) -> getParameter ( 'database_name' ) ; try { /** @var MySqlSchemaManager $schemaManager */ $ schemaManager = $ this -> getContainer ( ) -> get ( 'doctrine' ) -> getManager ( ) -> getConnection ( ) -> getSchemaManager ( ) ; } catch ( \ Exception $ exception ) { $ message = "SQLSTATE[42000] [1049] Unknown database '%s'" ; if ( false !== strpos ( $ exception -> getMessage ( ) , sprintf ( $ message , $ databaseName ) ) ) { return false ; } throw $ exception ; } try { return in_array ( $ databaseName , $ schemaManager -> listDatabases ( ) ) ; } catch ( \ PDOException $ e ) { return false ; } }
Is database exist

@return bool
@throws \Exception
Is database exist