]> source.dussan.org Git - nextcloud-server.git/commitdiff
improve detection of database backend
authorRobin Appelman <icewind1991@gmail.com>
Sun, 23 Oct 2011 10:29:12 +0000 (12:29 +0200)
committerRobin Appelman <icewind1991@gmail.com>
Sun, 23 Oct 2011 10:32:33 +0000 (12:32 +0200)
lib/db.php

index 44be619fde15d5f2b87f72d6aefec93005c22f2c..58479bacfb9562abb3bbbd89187d05f9cda93574 100644 (file)
@@ -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;