Exemplo n.º 1
0
 /**
  * connects to migration.db, or creates if not found
  * @param string $path to migration.db, defaults to user data dir
  * @return bool whether the operation was successful
  */
 private static function connectDB($path = null)
 {
     // Has the dbpath been set?
     self::$dbpath = !is_null($path) ? $path : self::$dbpath;
     if (!self::$dbpath) {
         OC_Log::write('migration', 'connectDB() was called without dbpath being set', OC_Log::ERROR);
         return false;
     }
     // Already connected
     if (!self::$migration_database) {
         $datadir = OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data");
         $connectionParams = array('path' => self::$dbpath, 'driver' => 'pdo_sqlite');
         $connectionParams['adapter'] = '\\OC\\DB\\AdapterSqlite';
         $connectionParams['wrapperClass'] = 'OC\\DB\\Connection';
         $connectionParams['tablePrefix'] = '';
         // Try to establish connection
         self::$migration_database = \Doctrine\DBAL\DriverManager::getConnection($connectionParams);
     }
     return true;
 }