protected function DbImportCommand::runScript in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Command/DbImportCommand.php \Drupal\Core\Command\DbImportCommand::runScript()
- 9 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.
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 (substr($script, -3) == '.gz') {
$script = "compress.zlib://{$script}";
}
try {
require $script;
} catch (SchemaObjectExistsException $e) {
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);
}