function DbDumpCommand::getTableCollation
Same name in other branches
- 9 core/lib/Drupal/Core/Command/DbDumpCommand.php \Drupal\Core\Command\DbDumpCommand::getTableCollation()
- 8.9.x core/lib/Drupal/Core/Command/DbDumpCommand.php \Drupal\Core\Command\DbDumpCommand::getTableCollation()
- 10 core/lib/Drupal/Core/Command/DbDumpCommand.php \Drupal\Core\Command\DbDumpCommand::getTableCollation()
Set the table collation.
Parameters
\Drupal\Core\Database\Connection $connection: The database connection to use.
string $table: The table to find indexes for.
array &$definition: The schema definition to modify.
1 call to DbDumpCommand::getTableCollation()
- DbDumpCommand::getTableSchema in core/
lib/ Drupal/ Core/ Command/ DbDumpCommand.php - Returns a schema array for a given table.
File
-
core/
lib/ Drupal/ Core/ Command/ DbDumpCommand.php, line 277
Class
- DbDumpCommand
- Provides a command to dump the current database to a script.
Namespace
Drupal\Core\CommandCode
protected function getTableCollation(Connection $connection, $table, &$definition) {
// Remove identifier quotes from the table name. See
// \Drupal\mysql\Driver\Database\mysql\Connection::$identifierQuotes.
$table = trim($connection->prefixTables('{' . $table . '}'), '"');
$query = $connection->query("SHOW TABLE STATUS WHERE NAME = :table_name", [
':table_name' => $table,
]);
$data = $query->fetchAssoc();
// Map the collation to a character set. For example, 'utf8mb4_general_ci'
// (MySQL 5) or 'utf8mb4_0900_ai_ci' (MySQL 8) will be mapped to 'utf8mb4'.
[
$charset,
] = explode('_', $data['Collation'], 2);
// Set `mysql_character_set`. This will be ignored by other backends.
$definition['mysql_character_set'] = $charset;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.