Many database libraries come setup for multiple database connections – but I’ve never actually known of an scripting application that needed to connect to two databases during it’s run. (compiled, daemon-running languages are a different matter).
I understand having database slaves so that you can spread the load out – but usually on startup only one of them is chosen to handle that scripts needs.
So why would a PHP or Ruby application need to connect to more than one database? Or rather, why would you split your data up among several databases?
The only thing I can think of is bad design from a slowly evolving system that started off in multiple separate parts.
Are you talking about different physical database servers or different databases in the “schema” sense?
Regarding physical servers, If you’re using MySQL replication you might write to a master and always read from a slave. This helps split the load among each database.