function drush_sql_su

6.x sql.drush.inc drush_sql_su($db_spec, $site_alias_record = NULL)
4.x sql.drush.inc drush_sql_su($db_spec)
5.x sql.drush.inc drush_sql_su($db_spec, $site_alias_record = NULL)
2 calls to drush_sql_su()

File

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

Code

function drush_sql_su($db_spec, $site_alias_record = NULL) {
  $create_db_target = $db_spec;
  $create_db_target['database'] = '';
  $db_superuser = drush_sitealias_get_option($site_alias_record, 'db-su');
  if (isset($db_superuser)) {
    $create_db_target['username'] = $db_superuser;
  }
  $db_su_pw = drush_sitealias_get_option($site_alias_record, 'db-su-pw');
  // If --db-su-pw is not provided and --db-su is, default to empty password.
  // This way db cli command will take password from .my.cnf or .pgpass.
  if (!empty($db_su_pw)) {
    $create_db_target['password'] = $db_su_pw;
  }
  elseif (isset($db_superuser)) {
    unset($create_db_target['password']);
  }
  return $create_db_target;
}