function drush_convert_db_from_db_url

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

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

Parameters

db_url: A Drupal 6 db-url string to convert.

Return value

array An array of database values.

4 calls to drush_convert_db_from_db_url()
drush_core_site_install_db_spec in commands/core/site_install.drush.inc
drush_sitealias_convert_db_from_db_url in includes/sitealias.inc
_drush_sql_get_db_spec in commands/sql/sql.drush.inc
Get a database specification for the active DB connection. Honors the 'database' and 'target command' line options.
_drush_sql_get_spec_from_options in commands/sql/sql.drush.inc

File

includes/sitealias.inc, line 1158
The site alias API.

Code

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,
    'port' => NULL,
    'database' => NULL,
  );
  $url = (object) $url;
  return array(
    'driver' => $url->scheme == 'mysqli' ? 'mysql' : $url->scheme,
    'username' => urldecode($url->user),
    'password' => urldecode($url->pass),
    'port' => urldecode($url->port),
    'host' => urldecode($url->host),
    'database' => substr(urldecode($url->path), 1), // skip leading '/' character
  );
}