Exemple #1
0
 public function save($runValidation = true, $attributes = NULL)
 {
     $a = parent::save($runValidation, $attributes);
     if ($a) {
         Yii::$app->db->close();
         Yii::$app->db->dsn = $this->company->string;
         Yii::$app->db->tablePrefix = $this->company->prefix;
         Yii::$app->db->open();
         $user = User::findOne($this->user_id);
         $user->save();
     }
     return $a;
 }
Exemple #2
0
 public function afterFind()
 {
     $this->certpasswd = $this->getCertPasswd();
     return parent::afterFind();
 }
Exemple #3
0
 public function save($runValidation = true, $attributes = NULL)
 {
     $a = parent::save($runValidation, $attributes);
     if ($this->prefix == '') {
         $this->string = Yii::$app->dbMain->dsn;
         //$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
         $this->prefix = "CA" . $this->id . "_";
         //got prefix
         $a = parent::save($runValidation, $attributes);
     }
     //if tables config notexsits
     Yii::$app->db->close();
     Yii::$app->db->dsn = $this->string;
     Yii::$app->db->tablePrefix = $this->prefix;
     Yii::$app->db->open();
     //needs to clear accounts
     if (Yii::$app->db->schema->getTableSchema('{{config}}') === null) {
         //
         //create tables
         $this->createDb();
         Yii::$app->db->close();
         Yii::$app->db->dsn = $this->string;
         Yii::$app->db->tablePrefix = $this->prefix;
         Yii::$app->db->open();
         \app\helpers\Linet3Helper::setSetting('company.path', $this->prefix);
         //update path by prefix
         //$yiiBasepath = Yii::$app->basePath;
         //add permisstions
     } else {
         //else
         //table version
         //upgrade
     }
     $perm = new DatabasesPerm();
     $perm->user_id = Yii::$app->user->id;
     $perm->database_id = $this->id;
     $perm->level_id = 1;
     $perm->save();
     return $a;
 }