In settings I have:
$db_url['default'] = 'mysql://aaa';
$db_url['depletion'] = 'mysql://bbb';
In my custom module I have:
db_set_active('depletion');
.
.
.
db_set_active('default');
Even with nothing but commented out lines between them, I get the following error:
user error: Table 'local_aspo.blocks' doesn't exist
query: SELECT * FROM blocks WHERE status = 1 AND region = 0 ORDER BY weight, module in /.[snip]./database.mysql.inc on line 66.
I've tried removing the word 'default' from the 'default' db_set_active which makes no change.
BUT... when I change it to:
db_set_active('anything-else-but-default-or-depletion');
... it bizarrely works!
I'm using a two-day old 4.6RC. db_set_active is:
function db_set_active($name = 'default') {
global $db_url, $db_type, $active_db;
static $db_conns;
if (!isset($db_conns[$name])) {
// Initiate a new connection, using the named DB URL specified.
if (is_array($db_url)) {
$connect_url = array_key_exists($name, $db_url) ? $db_url[$name] : $db_url['default'];
}
else {
$connect_url = $db_url;
}
$db_type = substr($connect_url, 0, strpos($connect_url, '://'));
$handler = "includes/database.$db_type.inc";
if (is_file($handler)) {
include_once($handler);
}
else {
die('Unsupported database type');