settings.php allows you to specify multiple database connection strings by name. this patch enables 'drush status' to output correctly all available connection strings and mark which one is active.

CommentFileSizeAuthor
#1 db_url_as_array_support.patch1.87 KBlitwol

Comments

litwol’s picture

StatusFileSize
new1.87 KB

And the patch ....

moshe weitzman’s picture

Status: Needs review » Needs work

Seems better to let drush_print() use print_r() instead of print

litwol’s picture

Here is output using print_r method in drush_print, and the second is using my patch.

Array
(
    [default] => mysql://<user>:<pass>@localhost/db1
    [tw] => mysql://<user>:<pass>@localhost/db2
)
Connection name         Connection string
---------------         -----------------
default (active)        mysql://<user>:<pass>@localhost/db1
tw                      mysql://<user>:<pass>@localhost/db2

While the first one is easiest and achieved with just one LOC inside core_commands_status, i do think we could do better by providing more aesthetic output.

I will provide patch for drush_print, but for the sakes of this discussion here's my change to drush_print() :

  print (is_array($message) || is_object($message)) ? print_r($message, TRUE) : str_repeat(' ', $indent) . (string)$message . "\n";

@Moshe Weitzman
Please advise which method you will accept and i will provide the appropriate patch.

Thanks.

moshe weitzman’s picture

Hmm. We made backward progress on this recently.

moshe weitzman’s picture

Status: Needs work » Fixed

drush sa --with-db default ... replace default with a different subdir of sites if you use multisite.

status shows the active connection which is enough IMO

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.