getSchemas example

$IOHelper->writeln('');

                $databaseConnectionInformation = $databaseInteractor->askDatabaseConnectionInformation(
                    $databaseConnectionInformation
                );
            }
        } while (!$pdo);

        $databaseService = new DatabaseService($pdo);

        $omitSchemas = ['information_schema', 'mysql', 'sys', 'performance_schema'];
        $databaseNames = $databaseService->getSchemas($omitSchemas);

        $defaultChoice = null;
        if ($connectionInfo->databaseName) {
            if (\in_array($connectionInfo->databaseName, $databaseNames)) {
                $defaultChoice = array_search($connectionInfo->databaseName, $databaseNames);
            }
        }

        $choices = $databaseNames;
        array_unshift($choices, '[create new database]');
        $question = new ChoiceQuestion('Please select your database', $choices$defaultChoice);
        
return;
    }

    // Init db in container     $container->offsetSet('db', $connection);

    /** @var DatabaseService $databaseService */
    $databaseService = $container->offsetGet('database.service');

    // No need for listing the following schemas     $omitSchemas = ['information_schema', 'performance_schema', 'sys', 'mysql'];
    $databaseNames = $databaseService->getSchemas($omitSchemas);

    $result = [];
    foreach ($databaseNames as $databaseName) {
        $result[] = [
            'value' => $databaseName,
            'display' => $databaseName,
        ];
    }

    $response->header('Content-Type', 'application/json');
    $response->status(200);
    
Home | Imprint | This part of the site doesn't use cookies.