protected function DbDumpCommand::generateScript
protected DbDumpCommand::generateScript(Connection $connection, array $schema_only = [])
Generates the database script.
Parameters
\Drupal\Core\Database\Connection $connection: The database connection to use.
array $schema_only: Table patterns for which to only dump the schema, no data.
Return value
string The PHP script. The PHP script.
File
- core/lib/Drupal/Core/Command/DbDumpCommand.php, line 75
Class
- DbDumpCommand
- Provides a command to dump the current database to a script.
Namespace
Drupal\Core\CommandCode
protected function generateScript(Connection $connection, array $schema_only = []) { $tables = ''; $schema_only_patterns = []; foreach ($schema_only as $match) { $schema_only_patterns[] = '/^' . $match . '$/'; } foreach ($this->getTables($connection) as $table) { $schema = $this->getTableSchema($connection, $table); // Check for schema only. if (empty($schema_only_patterns) || preg_replace($schema_only_patterns, '', $table)) { $data = $this->getTableData($connection, $table); } else { $data = []; } $tables .= $this->getTableScript($table, $schema, $data); } $script = $this->getTemplate(); // Substitute in the tables. $script = str_replace('{{TABLES}}', trim($tables), $script); return trim($script); }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Command!DbDumpCommand.php/function/DbDumpCommand::generateScript/8.1.x