I'm trying to use the Silverstripe DB class to access data from other existing databases. I've tried the following code snippet but it doesn't restore the previous connection causing all normal SilverStripe queries to try (and fail) to act on the second database. Is this possible? Should I just give up and use adodb?
class Product extends Page {
function test1() {
$oldConn = DB:getConn();
$otherDB = array(
"type" => "MySQLDatabase",
"server" => "localhost",
"username" => "******",
"password" => "******",
"database" => "TestDatabase",
);
DB::connect($otherDB);
$rs = DB::query("SELECT * FROM products");
Debug::show($rs->record());
DB::setConn($oldConn);
}
}