Skip to content

Commit

Permalink
Dev: moved Database creation to yii completely
Browse files Browse the repository at this point in the history
  • Loading branch information
lacrioque committed Oct 2, 2017
1 parent d22f0f2 commit f2ebcac
Show file tree
Hide file tree
Showing 3 changed files with 958 additions and 51 deletions.
14 changes: 8 additions & 6 deletions application/controllers/InstallerController.php
Expand Up @@ -487,7 +487,7 @@ function stepCreateDb()
if ($bCreateDB) //Database has been successfully created
{
$sDsn = self::_getDsn($sDatabaseType, $sDatabaseLocation, $sDatabasePort, $sDatabaseName, $sDatabaseUser, $sDatabasePwd);
$this->connection = new CDbConnection($sDsn, $sDatabaseUser, $sDatabasePwd);
$this->connection = new DbConnection($sDsn, $sDatabaseUser, $sDatabasePwd);

Yii::app()->session['populatedatabase'] = true;
Yii::app()->session['databaseexist'] = true;
Expand Down Expand Up @@ -574,7 +574,7 @@ function stepPopulateDb()
}

//checking DB Connection
$aErrors = self::_setup_tables(dirname(APPPATH).'/installer/sql/create-'.$sql_file.'.sql');
$aErrors = self::_setup_tables(dirname(APPPATH).'/installer/php/create-database.php');
if ($aErrors === false)
{
$model->addError('dblocation', gT('Try again! Connection with database failed. Reason: ').implode(', ', $aErrors));
Expand Down Expand Up @@ -965,8 +965,10 @@ function _setup_tables($sFileName, $aDbConfig = array(), $sDatabasePrefix = '')
} catch(Exception $e) {
return array($e->getMessage());
}

return $this->_executeSQLFile($sFileName, $sDatabasePrefix);
require_once($sFileName);
return createDatabase($this->connection);
//return $this->_executeSQLFile($sFileName, $sDatabasePrefix);
//return $this->_runDatabaseInstaller($sFileName, $sDatabasePrefix);
}

/**
Expand Down Expand Up @@ -1298,7 +1300,7 @@ function _dbConnect($aDbConfig = array(), $aData = array())
}
try
{
$this->connection = new CDbConnection($sDsn, $sDatabaseUser, $sDatabasePwd);
$this->connection = new DbConnection($sDsn, $sDatabaseUser, $sDatabasePwd);
if($sDatabaseType!='sqlsrv' && $sDatabaseType!='dblib')
{
$this->connection->emulatePrepare = true;
Expand Down Expand Up @@ -1359,7 +1361,7 @@ private function dbTest($aDbConfig = array(), $aData = array())
else
{
// Use same exception than Yii ? unclear
throw new CDbException('CDbConnection failed to open the DB connection.',(int)$e->getCode(),$e->errorInfo);
throw new DbConnection('CDbConnection failed to open the DB connection.',(int)$e->getCode(),$e->errorInfo);
}
}
$testPdo = null;
Expand Down

0 comments on commit f2ebcac

Please sign in to comment.