Calling all Drupal developers!
Help us get this on the first page of Digg. DIGG NOW!
Help us get this on the first page of Digg. DIGG NOW!
_drush_sql_get_credentials($db_url = NULL)
contributions/drush/drush_sql/drush_sql.module, line 291
<?php
function _drush_sql_get_credentials($db_url = NULL) {
if (is_null($db_url)) {
$db_url = $GLOBALS['db_url'];
}
// NOTE: this regex could also parse the connection string URL:
// ^([\w]+)://([\w\d_]+):([^@]*)@([\w\d\.\-]*)/([\w\d_]+)$
$url = (object)parse_url($db_url);
$url->user = urldecode($url->user);
$url->pass = urldecode($url->pass);
$url->host = urldecode($url->host);
$url->path = substr(urldecode($url->path), 1); // skip leading '/' character
switch ($url->scheme) {
case 'mysql':
case 'mysqli':
return ' -h' . $url->host .
(!isset($url->port) ? '' : ' -P' . $url->port) .
' -u' . $url->user .
(empty($url->pass) ? '' : ' -p' . $url->pass) . ' ' . $url->path;
case 'pgsql':
drush_die(t('Sorry, psql support not implemented yet.')); // TODO: psql credentials.
return;
default:
drush_die(_drush_sql_get_invalid_url_msg());
}
}
?>