If you have total control over application A which contains the bridge code, the easiest is to change it to use a different global variable, $dbA. This must not be doable or you wouldn't have asked. If you have control over the bridge code, and it alone calls A and B, then you could swap the $db variables between calls: $db = null; $dbA = null; $dbB = null; function copyPersons() { useA(); $persons = loadPersonsFromA(); useB(); savePersonsInB($persons); } function connect() { global $db, $dbA, $dbB; connectToA(); $dbA = $db; unset($db); connectToB(); $dbB = $db; unset($db); } function useA() { global $db, $dbA; $db = $dbA; } function useB() { global $db, $dbB; $db = $dbB; } This is the simplest implementation. You could get trickier by tracking which system is in use and only swapping them as-needed, writing a facade around the APIs to A and B. It's ugly, but it works. David