当前位置: 首页>>代码示例>>PHP>>正文


PHP Migration::init方法代码示例

本文整理汇总了PHP中yii\db\Migration::init方法的典型用法代码示例。如果您正苦于以下问题:PHP Migration::init方法的具体用法?PHP Migration::init怎么用?PHP Migration::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\db\Migration的用法示例。


在下文中一共展示了Migration::init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (Yii::$app->db->driverName === 'mysql') {
         $this->tableOptions = 'ENGINE=InnoDB CHARACTER SET=utf8 COLLATE=utf8_unicode_ci';
     }
 }
开发者ID:ssjssh,项目名称:yii2.0.6-with-annotate,代码行数:10,代码来源:Migration.php

示例2: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->db->driverName === 'mysql') {
         $this->tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
     }
 }
开发者ID:singleso,项目名称:singleso,代码行数:10,代码来源:Migration.php

示例3: init

 public function init()
 {
     parent::init();
     Yii::setAlias('@webroot', '@frontend/web');
     Yii::setAlias('@web', '/');
     Yii::$app->set('assetManager', $this->assetManager);
 }
开发者ID:lav45,项目名称:yii2-translated-behavior-demo,代码行数:7,代码来源:m160418_201842_page_data.php

示例4: init

 /**
  * 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.');
     }
 }
开发者ID:jarrus90,项目名称:yii2-user,代码行数:15,代码来源:RbacMigration.php

示例5: init

 /**
  * @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)']);
     }
 }
开发者ID:ivan-chkv,项目名称:yii2-boost,代码行数:12,代码来源:Migration.php

示例6: init

 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;
     }
 }
开发者ID:zwq,项目名称:yii2_restful,代码行数:9,代码来源:Migration.php

示例7: init

 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");
     }
 }
开发者ID:johnitvn,项目名称:mg075hynlo5793r5gt,代码行数:9,代码来源:BaseMigration.php

示例8: init

 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;
 }
开发者ID:artkost,项目名称:yii2-attachment,代码行数:10,代码来源:m141207_024254_create_attachment_table.php

示例9: init

 /**
  * {@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;
     }
 }
开发者ID:yii2mod,项目名称:base,代码行数:14,代码来源:Migration.php

示例10: init

 /**
  * 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 = '';
         }
     }
 }
开发者ID:nkovacs,项目名称:yii2-table-builder,代码行数:15,代码来源:Migration.php

示例11: init

 /**
  * @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.');
         }
     }
 }
开发者ID:nox-it,项目名称:yii2-nox-migration,代码行数:16,代码来源:Migration.php

示例12: init

 /**
  * @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();
 }
开发者ID:sirroland,项目名称:yii2-migen,代码行数:14,代码来源:Migration.php

示例13: init

 /**
  * @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!');
     }
 }
开发者ID:chabberwock,项目名称:halo-dev,代码行数:15,代码来源:Migration.php

示例14: init

 /**
  * @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!');
     }
 }
开发者ID:chd7well,项目名称:yii2-user,代码行数:17,代码来源:Migration.php

示例15: init

 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");
     }
 }
开发者ID:dmstr,项目名称:yii2-db,代码行数:14,代码来源:FileMigration.php


注:本文中的yii\db\Migration::init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。