}
class OC_Setup {
- static $db_setup_classes = array(
+ static $dbSetupClasses = array(
'mysql' => '\OC\Setup\MySQL',
'pgsql' => '\OC\Setup\PostgreSQL',
'oci' => '\OC\Setup\OCI',
$options['directory'] = OC::$SERVERROOT."/data";
}
- if (!isset(self::$db_setup_classes[$dbtype])) {
+ if (!isset(self::$dbSetupClasses[$dbtype])) {
$dbtype = 'sqlite';
}
- $class = self::$db_setup_classes[$dbtype];
- $db_setup = new $class(self::getTrans());
- $error = array_merge($error, $db_setup->validate($options));
+ $class = self::$dbSetupClasses[$dbtype];
+ $dbSetup = new $class(self::getTrans(), 'db_structure.xml');
+ $error = array_merge($error, $dbSetup->validate($options));
if(count($error) != 0) {
return $error;
OC_Config::setValue('dbtype', $dbtype);
OC_Config::setValue('version', implode('.', OC_Util::getVersion()));
try {
- $db_setup->initialize($options);
- $db_setup->setupDatabase($username);
+ $dbSetup->initialize($options);
+ $dbSetup->setupDatabase($username);
} catch (DatabaseSetupException $e) {
$error[] = array(
'error' => $e->getMessage(),
abstract class AbstractDatabase {
protected $trans;
+ protected $dbDefinitionFile;
protected $dbuser;
protected $dbpassword;
protected $dbname;
protected $dbhost;
protected $tableprefix;
- public function __construct($trans) {
+ public function __construct($trans, $dbDefinitionFile) {
$this->trans = $trans;
+ $this->dbDefinitionFile = $dbDefinitionFile;
}
public function validate($config) {
$row=mysql_fetch_row($result);
}
if(!$result or $row[0]==0) {
- \OC_DB::createDbFromStructure('db_structure.xml');
+ \OC_DB::createDbFromStructure($this->dbDefinitionFile);
}
mysql_close($connection);
}
}
//in case of sqlite, we can always fill the database
error_log("creating sqlite db");
- \OC_DB::createDbFromStructure('db_structure.xml');
+ \OC_DB::createDbFromStructure($this->dbDefinitionFile);
}
}