function drush_sitealias_add_db_settings

8.0.x sitealias.inc drush_sitealias_add_db_settings(&$alias_record)
6.x sitealias.inc drush_sitealias_add_db_settings(&$alias_record)
7.x sitealias.inc drush_sitealias_add_db_settings(&$alias_record)
3.x sitealias.inc drush_sitealias_add_db_settings(&$alias_record)
4.x sitealias.inc drush_sitealias_add_db_settings(&$alias_record)
5.x sitealias.inc drush_sitealias_add_db_settings(&$alias_record)
master sitealias.inc drush_sitealias_add_db_settings(&$alias_record)

If the alias record does not contain a 'databases' or 'db-url' entry, then use backend invoke to look up the settings value from the remote or local site. The 'databases' form is preferred; 'db_url' will be converted to 'databases' if necessary.

Parameters

$alias_record: The full alias record to populate with database settings

3 calls to drush_sitealias_add_db_settings()
drush_sitealias_add_db_url in includes/sitealias.inc
If the alias record does not contain a 'databases' or 'db-url' entry, then use backend invoke to look up the settings value from the remote or local site. The 'db_url' form is preferred; nothing is done if…
sitealias_get_databases_from_record in includes/sitealias.inc
Return the databases record from the alias record
_drush_sitealias_prepare_record in commands/core/sitealias.drush.inc
Given a site alias name, print out a php-syntax representation of it.

File

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

Code

function drush_sitealias_add_db_settings(&$alias_record) {
  $altered_record = FALSE;
  if (isset($alias_record['root'])) {
    // If the alias record does not have a defined 'databases' entry,
    // then we'll need to look one up
    if (!isset($alias_record['db-url']) && !isset($alias_record['databases']) && !isset($alias_record['site-list'])) {
      $values = drush_invoke_process($alias_record, "sql-conf", array(), array('all' => TRUE), array('integrate' => FALSE, 'override-simulated' => TRUE));
      if (is_array($values) && ($values['error_status'] == 0)) {
        $altered_record = TRUE;
        // If there are any special settings in the '@self' record returned by drush_invoke_process,
        // then add those into our altered record as well
        if (array_key_exists('self', $values)) {
          $alias_record = array_merge($values['self'], $alias_record);
        }
        drush_sitealias_cache_db_settings($alias_record, $values['object']);
      }
    }
  }
  return $altered_record;
}