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. If the parse fails the array is empty.

3 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_get_class in commands/sql/
Wrapper for drush_get_class; instantiates an driver-specific instance of SqlBase class.


includes/, line 1618
The site alias API.


function drush_convert_db_from_db_url($db_url) {
  $db_spec = array();

  if (is_array($db_url)) {
    $db_url_default = $db_url['default'];
  else {
    $db_url_default = $db_url;

  // If it's a sqlite database, pick the database path and we're done.
  if (strpos($db_url_default, 'sqlite://') === 0) {
    $db_spec = array(
      'driver' => 'sqlite',
      'database' => substr($db_url_default, strlen('sqlite://')),
  else {
    $url = parse_url($db_url_default);
    if ($url) {
      // Fill in defaults to prevent notices.
      $url += array(
        'scheme' => NULL,
        'user' => NULL,
        'pass' => NULL,
        'host' => NULL,
        'port' => NULL,
        'path' => NULL,
      $url = (object) array_map('urldecode', $url);
      $db_spec = array(
        'driver' => $url->scheme == 'mysqli' ? 'mysql' : $url->scheme,
        'username' => $url->user,
        'password' => $url->pass,
        'host' => $url->host,
        'port' => $url->port,
        'database' => ltrim($url->path, '/'),

  return $db_spec;