diff options
author | Robin Appelman <icewind1991@gmail.com> | 2011-10-23 12:29:12 +0200 |
---|---|---|
committer | Robin Appelman <icewind1991@gmail.com> | 2011-10-23 12:32:33 +0200 |
commit | 6592fbb948153e17dc90d1e167060a1d5c5bbe40 (patch) | |
tree | d8fbe85f1ed88e03dbd57dd4467f53bca15e5654 /lib/db.php | |
parent | 4140a75a5e2124dd81f362881cd2c5d2b9a26b9a (diff) | |
download | nextcloud-server-6592fbb948153e17dc90d1e167060a1d5c5bbe40.tar.gz nextcloud-server-6592fbb948153e17dc90d1e167060a1d5c5bbe40.zip |
improve detection of database backend
Diffstat (limited to 'lib/db.php')
-rw-r--r-- | lib/db.php | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/db.php b/lib/db.php index 44be619fde1..58479bacfb9 100644 --- a/lib/db.php +++ b/lib/db.php @@ -42,11 +42,22 @@ class OC_DB { * * Connects to the database as specified in config.php */ - public static function connect(){ + public static function connect($backend=null){ if(self::$connection){ return; } - if(class_exists('PDO') && OC_Config::getValue('installed', false)){//check if we can use PDO, else use MDB2 (instalation always needs to be done my mdb2) + if(is_null($backend)){ + $backend=self::BACKEND_MDB2; + if(class_exists('PDO') && OC_Config::getValue('installed', false)){//check if we can use PDO, else use MDB2 (instalation always needs to be done my mdb2) + $type = OC_Config::getValue( "dbtype", "sqlite" ); + if($type=='sqlite3') $type='sqlite'; + $drivers=PDO::getAvailableDrivers(); + if(array_search($type,$drivers)!==false){ + $backend=self::BACKEND_PDO; + } + } + } + if($backend==self::BACKEND_PDO){ self::connectPDO(); self::$connection=self::$PDO; self::$backend=self::BACKEND_PDO; |