function DbDumpCommand::execute

Same name in other branches
  1. 9 core/lib/Drupal/Core/Command/DbDumpCommand.php \Drupal\Core\Command\DbDumpCommand::execute()
  2. 8.9.x core/lib/Drupal/Core/Command/DbDumpCommand.php \Drupal\Core\Command\DbDumpCommand::execute()
  3. 11.x core/lib/Drupal/Core/Command/DbDumpCommand.php \Drupal\Core\Command\DbDumpCommand::execute()

File

core/lib/Drupal/Core/Command/DbDumpCommand.php, line 52

Class

DbDumpCommand
Provides a command to dump the current database to a script.

Namespace

Drupal\Core\Command

Code

protected function execute(InputInterface $input, OutputInterface $output) : int {
    $connection = $this->getDatabaseConnection($input);
    // If not explicitly set, disable ANSI which will break generated php.
    if ($input->hasParameterOption([
        '--ansi',
    ]) !== TRUE) {
        $output->setDecorated(FALSE);
    }
    $schema_tables = $input->getOption('schema-only');
    $schema_tables = explode(',', $schema_tables);
    $insert_count = (int) $input->getOption('insert-count');
    $output->writeln($this->generateScript($connection, $schema_tables, $insert_count), OutputInterface::OUTPUT_RAW);
    return 0;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.