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.

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/
drush_sitealias_convert_db_from_db_url in includes/
_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.
_drush_sql_get_spec_from_options in commands/sql/


includes/, line 1158
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,
    '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