init() public method

This method will set [[db]] to be the 'db' application component, if it is null.
public init ( )
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (Yii::$app->db->driverName === 'mysql') {
         $this->tableOptions = 'ENGINE=InnoDB CHARACTER SET=utf8 COLLATE=utf8_unicode_ci';
     }
 }
Beispiel #2
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->db->driverName === 'mysql') {
         $this->tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
     }
 }
 public function init()
 {
     parent::init();
     Yii::setAlias('@webroot', '@frontend/web');
     Yii::setAlias('@web', '/');
     Yii::$app->set('assetManager', $this->assetManager);
 }
Beispiel #4
0
 /**
  * Initialize migrations.
  * Calls parent init method, then loads current authManager instance.
  * 
  * @return DbManager
  * @throws yii\base\InvalidConfigException
  */
 public function init()
 {
     parent::init();
     $this->authManager = Yii::$app->getAuthManager();
     if (!$this->authManager instanceof DbManager) {
         throw new InvalidConfigException('You should configure "authManager" component to use database before executing this migration.');
     }
 }
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->db->driverName === 'mysql') {
         // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
         $this->tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
     }
 }
Beispiel #6
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     $db = $this->getDb();
     if (in_array($db->getDriverName(), ['mysql', 'mysqli'])) {
         $queryBuilder = $db->getQueryBuilder();
         $queryBuilder->typeMap = array_merge($queryBuilder->typeMap, [Schema::TYPE_UPK => str_replace('(11)', '(10)', $queryBuilder->typeMap[Schema::TYPE_UPK]), 'tinyint' => 'tinyint(4)', 'utinyint' => 'tinyint(3)', 'usmallint' => 'smallint(5)', 'uinteger' => 'int(10)']);
     }
 }
Beispiel #7
0
 public function init()
 {
     parent::init();
     if ($this->db->driverName === 'mysql') {
         //Mysql 表选项
         $engine = $this->useTransaction ? 'InnoDB' : 'MyISAM';
         $this->tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=' . $engine;
     }
 }
 public function init()
 {
     parent::init();
     if ($this->db->driverName === 'mysql') {
         $this->tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
     } else {
         throw new InvalidConfigException($this->db->driverName . " is not support");
     }
 }
 public function init()
 {
     parent::init();
     /** @var Manager $attachment */
     $attachment = Manager::getInstance();
     if (!$attachment instanceof Manager) {
         throw new InvalidConfigException('Attachment Manager component not defined');
     }
     $this->attachmentTable = $attachment->attachmentFileTable;
 }
Beispiel #10
0
 /**
  * {@inheritdoc}
  */
 public function init()
 {
     parent::init();
     switch (Yii::$app->db->driverName) {
         case 'mysql':
             $this->tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
             break;
         default:
             $this->tableOptions = null;
     }
 }
 /**
  * Initializes the migration.
  * This method will set tableOptions to use InnoDB if the db driver is mysql.
  */
 public function init()
 {
     parent::init();
     if ($this->tableOptions === true) {
         if ($this->db->driverName === 'mysql') {
             $this->tableOptions = 'ENGINE=InnoDB';
         } else {
             $this->tableOptions = '';
         }
     }
 }
Beispiel #12
0
 /**
  * @inheritdoc
  *
  * @throws NotSupportedException
  */
 public function init()
 {
     parent::init();
     if ($this->db->driverName === 'mysql') {
         $this->tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
     } else {
         if ((bool) $this->onlyMySql) {
             throw new NotSupportedException('MySQL required.');
         }
     }
 }
Beispiel #13
0
 /**
  * @throws \yii\base\InvalidConfigException
  */
 public function init()
 {
     if (is_null($this->_tableName)) {
         throw new InvalidConfigException('$_tableName must be set!');
     }
     if ($this->db->driverName === 'mysql' && $this->_tableOptions !== false) {
         // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
         $this->_tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
     }
     parent::init();
 }
Beispiel #14
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     switch (Yii::$app->db->driverName) {
         case 'mysql':
         case 'pgsql':
             $this->tableOptions = null;
             break;
         default:
             throw new \RuntimeException('Your database is not supported!');
     }
 }
Beispiel #15
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     switch (\Yii::$app->db->driverName) {
         case 'mysql':
             $this->tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
             break;
         case 'pgsql':
             $this->tableOptions = null;
             break;
         default:
             throw new \RuntimeException('Your database is not supported!');
     }
 }
Beispiel #16
0
 public function init()
 {
     parent::init();
     if ($this->file === null) {
         $reflection = new \ReflectionClass($this);
         $this->file = str_replace('.php', '.sql', $reflection->getFileName());
     } else {
         $reflection = new \ReflectionClass($this);
         $this->file = dirname($reflection->getFileName()) . DIRECTORY_SEPARATOR . $this->file;
     }
     if (!is_file($this->file)) {
         throw new Exception("File {$this->file} not found");
     }
 }
Beispiel #17
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     switch (Yii::$app->db->driverName) {
         case 'mysql':
             $this->tableOptions = 'ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci';
             $this->blobType = 'LONGBLOB';
             break;
         case 'pgsql':
             $this->blobType = 'BYTEA';
             break;
         default:
             throw new \RuntimeException('Your database is not supported!');
     }
 }
 public function init()
 {
     parent::init();
     if (isset(Yii::$app->params['superadmin.role.name'])) {
         $this->roleName = Yii::$app->params['superadmin.role.name'];
     }
     if (isset(Yii::$app->params['superadmin.permission.name'])) {
         $this->permissionName = Yii::$app->params['superadmin.permission.name'];
     }
     if (isset(Yii::$app->params['superadmin.user.login'])) {
         $this->userLogin = Yii::$app->params['superadmin.user.login'];
     }
     if (isset(Yii::$app->params['superadmin.user.password'])) {
         $this->userPassword = Yii::$app->params['superadmin.user.password'];
     } else {
         throw new InvalidConfigException('You should configure "superadmin.user.password" param in common/config/yiip/yii2-module-rbac/params.php to use superadmin role.');
     }
 }
Beispiel #19
0
 /**
  * Initializes the migration.
  * This method will set [[db]] to be the 'db' application component, if it is `null`.
  */
 public function init()
 {
     parent::init();
     if ($this->db->driverName === 'mysql') {
         switch ($this->encoding) {
             case 'utf8mb4':
                 $size = 191;
                 break;
             default:
                 $size = 255;
         }
         /* @var string MAX_CHAR_LENGTH the number of maximum allowed varchar size. */
         defined('MAX_CHAR_LENGTH') or define('MAX_CHAR_LENGTH', $size);
         $this->tableOptions = 'CHARACTER SET ';
         $this->tableOptions .= $this->encoding;
         $this->tableOptions .= ' COLLATE ';
         $this->tableOptions .= $this->collation;
         $this->tableOptions .= ' ENGINE=';
         $this->tableOptions .= $this->engine;
     }
 }
 public function init()
 {
     $this->db = 'dbForms';
     parent::init();
 }
 public function init()
 {
     parent::init();
     $this->_tableName = Yii::$app->getModule('pages')->tableName;
 }
 /**
  * Initializes the migration.
  * This method will set [[db]] to be the 'db' application component, if it is `null`.
  */
 public function init()
 {
     parent::init();
 }
 public function init()
 {
     $this->tableName = Book::tableName();
     parent::init();
 }
 /**
  * Checks $_rows parameter
  */
 public function init()
 {
     if ($this->_rows == null) {
         echo "Migration is empty\n";
         exit;
     }
     parent::init();
 }
 public function init()
 {
     parent::init();
     // TODO: Change the autogenerated stub
     $this->isMsSQL = $this->db->driverName == 'mssql' || $this->db->driverName == 'sqlsrv' || $this->db->driverName == 'dblib';
 }
 public function init()
 {
     parent::init();
     $this->tableName = Module::getInstance()->tableName;
 }
 public function init()
 {
     $this->fifteenMinutesAgo = strtotime('-15 minutes');
     parent::init();
 }
 public function init()
 {
     $this->db = 'dbSpider';
     parent::init();
 }
 public function init()
 {
     require_once Yii::getAlias($this->originalMigrationPath) . DIRECTORY_SEPARATOR . $this->originalMigrationName . '.php';
     $this->originalMigration = new $this->originalMigrationName();
     parent::init();
 }
 public function init()
 {
     $this->db = 'dbLogger';
     // custom db adapter for logs
     parent::init();
 }