function drush_sql_conf

8.0.x sql.drush.inc drush_sql_conf()
6.x sql.drush.inc drush_sql_conf()
7.x sql.drush.inc drush_sql_conf()
3.x sql.drush.inc drush_sql_conf()
4.x sql.drush.inc drush_sql_conf()
5.x sql.drush.inc drush_sql_conf()
master sql.drush.inc drush_sql_conf()

Command callback. Displays the Drupal site's database connection string.

File

commands/sql/sql.drush.inc, line 264
Drush sql commands

Code

function drush_sql_conf() {
  // Under Drupal 7, if the database is configured but empty, then
  // DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION will throw an exception.
  // If this happens, we'll just catch it and continue.
  // TODO:  Fix this in the bootstrap, per http://drupal.org/node/1996004
  try {
    drush_bootstrap_max(DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION);
  }
  catch (Exception $e) {
  }
  if (drush_get_option('db-url', FALSE)) {
    $db_spec['db-url'] = $GLOBALS['db_url'];
  }
  elseif (drush_get_option('all', FALSE)) {
    $db_spec = _drush_sql_get_all_db_specs();
  }
  if (!isset($db_spec)) {
    $db_spec = _drush_sql_get_db_spec();
  }
  $return = $db_spec;
  if (!drush_get_option('show-passwords', FALSE)) {
    drush_unset_recursive($db_spec, 'password');
  }
  drush_print_r($db_spec);
  return $return;
}