function DbImportCommand::runScript
Same name in other branches
- 9 core/lib/Drupal/Core/Command/DbImportCommand.php \Drupal\Core\Command\DbImportCommand::runScript()
- 8.9.x core/lib/Drupal/Core/Command/DbImportCommand.php \Drupal\Core\Command\DbImportCommand::runScript()
- 10 core/lib/Drupal/Core/Command/DbImportCommand.php \Drupal\Core\Command\DbImportCommand::runScript()
Run the database script.
Parameters
\Drupal\Core\Database\Connection $connection: Connection used by the script when included.
string $script: Path to dump script.
1 call to DbImportCommand::runScript()
- DbImportCommand::execute in core/
lib/ Drupal/ Core/ Command/ DbImportCommand.php
File
-
core/
lib/ Drupal/ Core/ Command/ DbImportCommand.php, line 56
Class
- DbImportCommand
- Provides a command to import the current database from a script.
Namespace
Drupal\Core\CommandCode
protected function runScript(Connection $connection, $script) {
$old_key = Database::setActiveConnection($connection->getKey());
if (str_ends_with($script, '.gz')) {
$script = "compress.zlib://{$script}";
}
try {
require $script;
} catch (SchemaObjectExistsException) {
throw new \RuntimeException('An existing Drupal installation exists at this location. Try removing all tables or changing the database prefix in your settings.php file.');
}
Database::setActiveConnection($old_key);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.