protected function DbDumpCommand::fieldSizeMap

protected DbDumpCommand::fieldSizeMap(Connection $connection, $type)

Given a database field type, return a Drupal size.

Parameters

\Drupal\Core\Database\Connection $connection: The database connection to use.

string $type: The MySQL field type.

Return value

string The Drupal schema field size.

File

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

Class

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

Namespace

Drupal\Core\Command

Code

protected function fieldSizeMap(Connection $connection, $type) {
  // Convert everything to lowercase.
  $map = array_map('strtolower', $connection->schema()->getFieldTypeMap());
  $map = array_flip($map);

  $schema_type = explode(':', $map[$type]) [0];
  // Only specify size on these types.
  if (in_array($schema_type, ['blob', 'float', 'int', 'text'])) {
    // The MySql map contains type:size. Remove the type part.
    return explode(':', $map[$type]) [1];
  }
}

© 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::fieldSizeMap/8.1.x