Alternate database setup

Since the database config is done with constants how do I go about switching to an alternate database while keeping the same referential syntax to db_* and sql_* functions?

Thanks!

Database Set up

Here's an example of working with a second db:
misc.php:

function &getSecondDb()
{
	if(isset($GLOBALS['secondDB']))
		return $GLOBALS['secondDB'];
	$dsn = database::makeDSN(second_rdbms, second_host, second_port, second_username, second_password, second_database);
	$GLOBALS['secondDB'] = &new database($dsn);
	return $GLOBALS['secondDB'];
}

zone_default.php:
function pageSecondDB($p, $z)
{
    $someVar = (int)$p[1];
    $db = &getSecondDb();
    $someId = $db->fetch_one_cell("select id from sometable where some_condition = $someVar");
    $someOtherItem = sql_fetch_one_cell("select * from someothertable where id = $someId");
}

Hope that's helpful.

john 09 Oct 2008