Exemple #1
0
 public static function updateConfigurables()
 {
     Yii::$app->set('db', Yii::createObject(InstallerHelper::createDatabaseConfig(Yii::$app->session->get('db-config'))));
     Yii::$app->db->open();
     $conf = Configurable::find()->all();
     return ConfigurationUpdater::updateConfiguration($conf, false);
 }
Exemple #2
0
 /**
  * @return bool If connection ok?
  */
 public function testConnection()
 {
     $config = InstallerHelper::createDatabaseConfig($this->getAttributes());
     $result = false;
     try {
         /** @var \yii\db\Connection $dbComponent */
         $dbComponent = Yii::createObject($config);
         $dbComponent->open();
         $result = true;
     } catch (\Exception $e) {
         Yii::$app->session->setFlash('danger', Yii::t('app', 'Database connection error:') . ' ' . $e->getMessage());
     }
     return $result;
 }
 private function checkTime($ignoreTimeLimit = false)
 {
     if (InstallerHelper::unlimitTime() === false && $ignoreTimeLimit === false) {
         Yii::$app->session->setFlash('warning', Yii::t('app', 'Can\'t set time limit to 0. Some operations may not complete.'));
         return false;
     } else {
         return true;
     }
 }
 /**
  * @return \yii\db\Connection
  * @throws \yii\base\InvalidConfigException
  */
 private function db()
 {
     if ($this->db === null) {
         $config = InstallerHelper::createDatabaseConfig($this->getDbConfigFromSession());
         $dbComponent = Yii::createObject($config);
         $dbComponent->open();
         $this->db = $dbComponent;
     }
     return $this->db;
 }