function drush_convert_db_from_db_url

8.0.x drush_convert_db_from_db_url($db_url)
6.x drush_convert_db_from_db_url($db_url)
7.x drush_convert_db_from_db_url($db_url)
3.x drush_convert_db_from_db_url($db_url)
4.x drush_convert_db_from_db_url($db_url)
5.x drush_convert_db_from_db_url($db_url)
master drush_convert_db_from_db_url($db_url)

Convert from an old-style database URL to an array of database settings


db_url: A Drupal 6 db-url string to convert, or an array with a 'default' element.

Return value

array An array of database values containing only the 'default' element of the db_url.

5 calls to drush_convert_db_from_db_url()
drush_archive_restore in commands/core/
Command callback. Restore web site(s) from a site archive file.
drush_sitealias_convert_db_from_db_url in includes/
Convert from an old-style database URL to an array of database settings
drush_sql_read_db_spec in commands/sql/
Return a db_spec based on supplied db_url/db_prefix options or an existing settings.php.
_drush_sql_get_db_spec in commands/sql/
Get a database specification for the active DB connection. Honors the 'database' and 'target command' line options. If not in a Drupal site, honors a --db-url option.
_drush_sql_get_spec_from_options in commands/sql/


includes/, line 1248
The site alias API.


function drush_convert_db_from_db_url($db_url) {
  if (is_array($db_url)) {
    $url = parse_url($db_url['default']);
  else {
    $url = parse_url($db_url);
  // Fill in defaults to prevent notices.
  $url += array(
    'driver' => NULL,
    'user' => NULL,
    'pass' => NULL,
    'host' => NULL,
    'port' => NULL,
    'database' => NULL,
  $url = (object) array_map('urldecode', $url);
  return array(
    'driver' => $url->scheme == 'mysqli' ? 'mysql' : $url->scheme,
    'username' => $url->user,
    'password' => $url->pass,
    'port' => $url->port,
    'host' => $url->host,
    // Remove leading / character from database names, unless we're installing
    // to SQLite (which won't have a slash there unless it's part of a path).
    'database' => $url->scheme === 'sqlite' ? $url->path : substr($url->path, 1),