src/PHPDish/Bundle/CoreBundle/Command/InstallDatabaseCommand.php
protected function isDatabasePresent()
    {
        $connection = $this->getContainer()->get('doctrine.dbal.default_connection');
        $databaseName = $connection->getDatabase();

        try {
            return in_array($databaseName, $connection->getSchemaManager()->listDatabases());
        } catch (\Exception $exception) {
            $message = $exception->getMessage();
            $mysqlDatabaseError = false !== strpos($message, sprintf("Unknown database '%s'", $databaseName));
            $postgresDatabaseError = false !== strpos($message, sprintf('database "%s" does not exist', $databaseName));

            if ($mysqlDatabaseError || $postgresDatabaseError) {
                return false;
            }

            throw $exception;
        }
    }
protected function isDatabasePresent()
    {
        $connection = $this->getContainer()->get('doctrine.dbal.default_connection');
        $databaseName = $connection->getDatabase();

        try {
            return in_array($databaseName, $connection->getSchemaManager()->listDatabases());
        } catch (\Exception $exception) {
            $message = $exception->getMessage();
            $mysqlDatabaseError = false !== strpos($message, sprintf("Unknown database '%s'", $databaseName));
            $postgresDatabaseError = false !== strpos($message, sprintf('database "%s" does not exist', $databaseName));

            if ($mysqlDatabaseError || $postgresDatabaseError) {
                return false;
            }

            throw $exception;
        }
    }
检查是否已经创建过数据库.

@throws \Exception

@return bool