allow changing database backends between PDO and MDB2

remotes/origin/stable
Robin Appelman 2012-01-08 02:57:52 +07:00
parent 010bfa11e3
commit 034cf19159
1 changed files with 19 additions and 4 deletions

@ -71,7 +71,14 @@ class OC_DB {
/** /**
* connect to the database using pdo * connect to the database using pdo
*/ */
private static function connectPDO(){ public static function connectPDO(){
if(self::$connection){
if(self::$backend==self::BACKEND_MDB2){
self::disconnect();
}else{
return;
}
}
// The global data we need // The global data we need
$name = OC_Config::getValue( "dbname", "owncloud" ); $name = OC_Config::getValue( "dbname", "owncloud" );
$host = OC_Config::getValue( "dbhost", "" ); $host = OC_Config::getValue( "dbhost", "" );
@ -113,7 +120,14 @@ class OC_DB {
/** /**
* connect to the database using mdb2 * connect to the database using mdb2
*/ */
static private function connectMDB2(){ public static function connectMDB2(){
if(self::$connection){
if(self::$backend==self::BACKEND_PDO){
self::disconnect();
}else{
return;
}
}
// The global data we need // The global data we need
$name = OC_Config::getValue( "dbname", "owncloud" ); $name = OC_Config::getValue( "dbname", "owncloud" );
$host = OC_Config::getValue( "dbhost", "" ); $host = OC_Config::getValue( "dbhost", "" );
@ -255,8 +269,8 @@ class OC_DB {
self::$connection->disconnect(); self::$connection->disconnect();
} }
self::$connection=false; self::$connection=false;
self::$mdb2=false; self::$MDB2=false;
self::$pdo=false; self::$PDO=false;
} }
return true; return true;
@ -374,6 +388,7 @@ class OC_DB {
private static function connectScheme(){ private static function connectScheme(){
// We need a mdb2 database connection // We need a mdb2 database connection
self::connectMDB2(); self::connectMDB2();
self::$MDB2->loadModule('Manager');
// Connect if this did not happen before // Connect if this did not happen before
if(!self::$schema){ if(!self::$schema){